Class: InternalTurnk

Inherits:
Object
  • Object
show all
Defined in:
lib/data/internalTurnk/classifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInternalTurnk

Returns a new instance of InternalTurnk.



10
11
12
13
14
15
16
17
# File 'lib/data/internalTurnk/classifier.rb', line 10

def initialize
   @classifier = Classifier::Bayes.new 
   @home_dir = FBayesDir.internal_turnk_data
   puts @home_dir.inspect

   add_categories
   train
end

Instance Attribute Details

#classifierObject

Returns the value of attribute classifier.



8
9
10
# File 'lib/data/internalTurnk/classifier.rb', line 8

def classifier
  @classifier
end

Instance Method Details

#c(word) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/data/internalTurnk/classifier.rb', line 19

def c(word)
  result = sorted_classification(word)
  value_of_classification = result.first.last
  category_of_classification = result.first.first

  if value_of_classification >= value_of_missing_info
    return category_of_classification
  elsif (result[0].last - result[1].last) >= 0.5
    return category_of_classification
  else
    return "Unknown"
  end
end

#d(word) ⇒ Object



33
34
35
# File 'lib/data/internalTurnk/classifier.rb', line 33

def d(word)
  @classifier.classifications(word)
end