Class: UtteranceParser::Utterance

Inherits:
Object
  • Object
show all
Defined in:
lib/utterance_parser/utterance.rb

Direct Known Subclasses

Example

Constant Summary collapse

TAG_RE =
/<(.+?)>(.*?)<.+?>/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Utterance

Returns a new instance of Utterance.



7
8
9
# File 'lib/utterance_parser/utterance.rb', line 7

def initialize(text)
  @text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/utterance_parser/utterance.rb', line 5

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
# File 'lib/utterance_parser/utterance.rb', line 11

def ==(other)
  other.class == self.class && other.text == @text
end

#pos_tokensObject



15
16
17
# File 'lib/utterance_parser/utterance.rb', line 15

def pos_tokens
  PosTagger.add_tags(@text).scan(TAG_RE).map { |tag, word| [word, tag.upcase] }
end