Class: YaCan::Keyphrase::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/yacan/keyphrase.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#resultsObject (readonly)

Returns the value of attribute results.



32
33
34
# File 'lib/yacan/keyphrase.rb', line 32

def results
  @results
end

#xmlObject (readonly)

Returns the value of attribute xml.



32
33
34
# File 'lib/yacan/keyphrase.rb', line 32

def xml
  @xml
end

Instance Method Details

#phrasesObject



24
25
26
# File 'lib/yacan/keyphrase.rb', line 24

def phrases
  @phrases ||= @results.map{ |r| r[0]}
end

#scoresObject



28
29
30
# File 'lib/yacan/keyphrase.rb', line 28

def scores
  @scores ||= @results.map{ |r| r[1]}
end