Class: NLP::Sentence

Inherits:
Object
  • Object
show all
Defined in:
lib/tagger/sentence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSentence

Returns a new instance of Sentence.



6
7
8
# File 'lib/tagger/sentence.rb', line 6

def initialize()
  @tokens = []
end

Instance Attribute Details

#tokensObject (readonly)

Returns the value of attribute tokens.



4
5
6
# File 'lib/tagger/sentence.rb', line 4

def tokens
  @tokens
end

Instance Method Details

#<<(tokens) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/tagger/sentence.rb', line 10

def << tokens
  if tokens.is_a? Array
    @tokens.concat tokens
  else
    @tokens << tokens
  end
  self
end

#words_numberObject



19
20
21
# File 'lib/tagger/sentence.rb', line 19

def words_number
  @tokens.count{|t| !t.interp?}
end