Class: RubyTokenizer::Tokenizer
- Inherits:
-
Object
- Object
- RubyTokenizer::Tokenizer
- Includes:
- Patterns
- Defined in:
- lib/ruby_tokenizer.rb
Constant Summary
Constants included from Patterns
Patterns::BASIC, Patterns::MISC, Patterns::PARENS, Patterns::PUNCTUATION
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text) ⇒ Tokenizer
constructor
A new instance of Tokenizer.
- #rank ⇒ Object
Methods included from Patterns
Constructor Details
#initialize(text) ⇒ Tokenizer
Returns a new instance of Tokenizer.
11 12 13 |
# File 'lib/ruby_tokenizer.rb', line 11 def initialize(text) @text = text end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'lib/ruby_tokenizer.rb', line 9 def text @text end |
Instance Method Details
#rank ⇒ Object
15 16 17 18 |
# File 'lib/ruby_tokenizer.rb', line 15 def rank ranked = Hash[self.frequency.sort_by { |_word, count| count }.reverse] ranked.first(10) end |