class Tagmemics::WordSet
The output of Tagmemics.parse
Constants
- ARTICLES
- CONJUNCTIONS
- LINKING_VERBS
- PREPOSITIONS
- PRONOUNS
Attributes
adjectives[RW]
adverbs[RW]
articles[RW]
collection[RW]
conjunctions[RW]
nouns[RW]
prepositions[RW]
pronouns[RW]
verbs[RW]
Public Class Methods
new(str)
click to toggle source
# File lib/tagmemics.rb, line 21 def initialize(str) @collection = [] arr = WordSet.sentence_to_array(str) arr.each { |word| @collection << Word.new(word) } # @set = WordSet.start_hash(WordSet.sentence_to_array(str)) end
sentence_to_array(sentence)
click to toggle source
Will probably want to use punctuation in the future. For now, this removes it.
# File lib/tagmemics.rb, line 33 def sentence_to_array(sentence) sentence.split(/\s+|\W+\z/) end
start_hash(arr)
click to toggle source
Moved part of speech. This will not work right now. Probably need to delete this.
# File lib/tagmemics.rb, line 39 def start_hash(arr) arr.map do |word| result = case when part_of_speech(ARTICLES, word).any? then :article when part_of_speech(CONJUNCTIONS, word).any? then :conjunction when part_of_speech(PRONOUNS, word).any? then :pronoun end [word, result] end.to_h end