Class: TextRazor::Phrase
- Inherits:
-
Object
- Object
- TextRazor::Phrase
- Defined in:
- lib/textrazor/phrase.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params, words) ⇒ Phrase
constructor
A new instance of Phrase.
- #match_words(positions, words) ⇒ Object
Constructor Details
#initialize(params, words) ⇒ Phrase
Returns a new instance of Phrase.
7 8 9 10 |
# File 'lib/textrazor/phrase.rb', line 7 def initialize(params, words) @id = params["id"] @text = match_words(params["wordPositions"], words) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/textrazor/phrase.rb', line 5 def id @id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/textrazor/phrase.rb', line 5 def text @text end |
Class Method Details
.create_from_hash(params, words) ⇒ Object
12 13 14 |
# File 'lib/textrazor/phrase.rb', line 12 def self.create_from_hash(params, words) new(params, words) end |
Instance Method Details
#match_words(positions, words) ⇒ Object
16 17 18 19 20 |
# File 'lib/textrazor/phrase.rb', line 16 def match_words(positions, words) phrase = [] positions.each { |position| phrase.push words[position].token } phrase.join(' ') end |