Class: Agenda::Analyzer
- Inherits:
-
Object
- Object
- Agenda::Analyzer
- Defined in:
- lib/agenda/analyzer.rb
Instance Method Summary collapse
-
#initialize(the_string) ⇒ Analyzer
constructor
A new instance of Analyzer.
- #tag_words ⇒ Object
- #word_count ⇒ Object
Constructor Details
#initialize(the_string) ⇒ Analyzer
Returns a new instance of Analyzer.
3 4 5 |
# File 'lib/agenda/analyzer.rb', line 3 def initialize(the_string) @the_string = the_string.force_encoding "UTF-8" end |
Instance Method Details
#tag_words ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/agenda/analyzer.rb', line 21 def tag_words the_word_array = word_count Agenda.dictionary.each do |name, words| the_word_array.each do |word| word. << name if words.include?(word.word) end end the_word_array end |
#word_count ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/agenda/analyzer.rb', line 7 def word_count words = WordArray.new the_discarded_regexp = Agenda.regexp["discarded"] @the_string.split(the_discarded_regexp).each do |word| if word != "" words << Word.new(word) unless words.has?(word) words.get(word).count += 1 end end words.order! return words end |