<commit_before>require_relative 'TrainingExamples.rb'

class TextClassifier
  def initialize( training_examples_path = 'training/')
    @examples = TrainingExamples.new(training_examples_path)
  end


  def classify(path)
    @text = File.read(path)
    words = @text.split(/\W+/)
    words = words.slice(0,100) # Use only the first 100 words for classification

    pIsInteristing = calculateProbabilities(words, "I")
    pIsNotInteristing = calculateProbabilities(words, "!I")

     if pIsInteristing > pIsNotInteristing
       puts "Interisting"
     else
       puts "Not interisting"
     end
  end

  private
    def calculateProbabilities(list_of_words, klass)
      p = @examples.p_apriori(klass)
      list_of_words.each do |word|<commit_msg>Added and true/false return value to the classify method of TextClassifier<commit_after>require_relative 'TrainingExamples.rb'

class TextClassifier
  def initialize( training_examples_path = 'training/')
    @examples = TrainingExamples.new(training_examples_path)
  end


  def classify(path)
    @text = File.read(path)
    words = @text.split(/\W+/)
    words = words.slice(0,100) # Use only the first 100 words for classification

    pIsInteristing = calculateProbabilities(words, "I")
    pIsNotInteristing = calculateProbabilities(words, "!I")

     if pIsInteristing > pIsNotInteristing
       puts "Interisting"
       return true
     else
       puts "Not interisting"
       return false
     end
  end

  private
    def calculateProbabilities(list_of_words, klass)
      p = @examples.p_apriori(klass)
      list_of_words.each do |word|
{'fraction_non_alphanumeric': 0.08551810237203496, 'fraction_numerical': 0.008739076154806492, 'mean_word_length': 3.632947976878613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1032454', 'n_tokens_mistral': 518, 'n_tokens_neox': 481, 'n_words': 119}