Class: NLP::Text
- Inherits:
-
Object
- Object
- NLP::Text
- Defined in:
- lib/tagger/text.rb
Instance Attribute Summary collapse
-
#sentences ⇒ Object
readonly
Returns the value of attribute sentences.
Instance Method Summary collapse
- #<<(sentence) ⇒ Object
- #flatten ⇒ Object
-
#initialize ⇒ Text
constructor
A new instance of Text.
- #words_per_sentence ⇒ Object
Constructor Details
#initialize ⇒ Text
Returns a new instance of Text.
5 6 7 |
# File 'lib/tagger/text.rb', line 5 def initialize @sentences = [] end |
Instance Attribute Details
#sentences ⇒ Object (readonly)
Returns the value of attribute sentences.
3 4 5 |
# File 'lib/tagger/text.rb', line 3 def sentences @sentences end |
Instance Method Details
#<<(sentence) ⇒ Object
9 10 11 |
# File 'lib/tagger/text.rb', line 9 def << sentence @sentences.push sentence end |
#flatten ⇒ Object
17 18 19 20 21 |
# File 'lib/tagger/text.rb', line 17 def flatten flattened = [] @sentences.each{ |s| s.tokens.each{|t| flattened.push t } } flattened end |
#words_per_sentence ⇒ Object
13 14 15 |
# File 'lib/tagger/text.rb', line 13 def words_per_sentence @sentences.collect{|s| s.words_number}.mean end |