module Tagmemics::WordNetMethods
Public Class Methods
combine_values(hsh)
click to toggle source
# File lib/tagmemics/word/wordnet.rb, line 51 def combine_values(hsh) hsh.values.reduce(:+) end
decimal_complete(hsh)
click to toggle source
TODO: Not using this. Delete?
# File lib/tagmemics/word/wordnet.rb, line 65 def decimal_complete(hsh) total = hsh.length complete = hsh.count { |_k, v| v } # not nil complete / total.to_f end
lex()
click to toggle source
# File lib/tagmemics/word/wordnet.rb, line 7 def lex WordNet::Lexicon.new end
most_likely_pos(probability_hsh)
click to toggle source
Most likely part of speech
# File lib/tagmemics/word/wordnet.rb, line 36 def most_likely_pos(probability_hsh) return unless probability_hsh.is_a? Hash max = probability_hsh.values.max probability_hsh.select { |_k, v| v == max } end
most_likely_probability(hsh)
click to toggle source
DELETE ME?
# File lib/tagmemics/word/wordnet.rb, line 47 def most_likely_probability(hsh) most_likely_pos(hsh).values.reduce(:+) end
parts_of_speech_frequency(word, arr = [])
click to toggle source
# File lib/tagmemics/word/wordnet.rb, line 16 def parts_of_speech_frequency(word, arr = []) word_definitions(word).each do |x| arr << x.part_of_speech end arr.frequency end
possibilities(word)
click to toggle source
returns hash of all possibilities for given dictionary word.
# File lib/tagmemics/word/wordnet.rb, line 28 def possibilities(word) hsh = parts_of_speech_frequency(word) denom = total_possibilities(word) hsh.each { |k, v| hsh[k] = v / denom.to_f } end
total_possibilities(word)
click to toggle source
# File lib/tagmemics/word/wordnet.rb, line 23 def total_possibilities(word) parts_of_speech_frequency(word).values.reduce(:+) end
word_definitions(word)
click to toggle source
# File lib/tagmemics/word/wordnet.rb, line 11 def word_definitions(word) word = word.to_sym lex.lookup_synsets(word) end
wordnet_probability(word, part_of_speech)
click to toggle source
Select highest probable part of speech and combine with any others with similiar name ie. Adjective and Adjective Satellite, they will be added together.
# File lib/tagmemics/word/wordnet.rb, line 58 def wordnet_probability(word, part_of_speech) hsh = possibilities(word) eligibles = hsh.select { |k, _v| k.split.include? part_of_speech } combine_values(eligibles) || 0.0 # return if probability is nil end