Class: YaCan::Keyphrase::Result
- Inherits:
-
Object
- Object
- YaCan::Keyphrase::Result
- Defined in:
- lib/yacan/keyphrase.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Result
constructor
A new instance of Result.
- #phrases ⇒ Object
- #scores ⇒ Object
Constructor Details
#initialize(xml) ⇒ Result
Returns a new instance of Result.
16 17 18 19 20 21 22 |
# File 'lib/yacan/keyphrase.rb', line 16 def initialize(xml) @xml = xml pairs = Nokogiri::XML(xml).search('Result') @results = pairs.map{ |p| [p.at('Keyphrase').text, p.at('Score').text.to_i] } end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
32 33 34 |
# File 'lib/yacan/keyphrase.rb', line 32 def results @results end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
32 33 34 |
# File 'lib/yacan/keyphrase.rb', line 32 def xml @xml end |
Instance Method Details
#phrases ⇒ Object
24 25 26 |
# File 'lib/yacan/keyphrase.rb', line 24 def phrases @phrases ||= @results.map{ |r| r[0]} end |
#scores ⇒ Object
28 29 30 |
# File 'lib/yacan/keyphrase.rb', line 28 def scores @scores ||= @results.map{ |r| r[1]} end |