Class: Opener::KAF::Term

Inherits:
Object
  • Object
show all
Defined in:
lib/opener/kaf/term.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, node) ⇒ Term

Returns a new instance of Term.



8
9
10
11
# File 'lib/opener/kaf/term.rb', line 8

def initialize document, node
  @document = document
  @node     = node
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



5
6
7
# File 'lib/opener/kaf/term.rb', line 5

def document
  @document
end

#nodeObject (readonly)

Returns the value of attribute node.



6
7
8
# File 'lib/opener/kaf/term.rb', line 6

def node
  @node
end

Instance Method Details

#idObject



13
14
15
# File 'lib/opener/kaf/term.rb', line 13

def id
  @id ||= @node.attr :tid
end

#lemmaObject



17
18
19
# File 'lib/opener/kaf/term.rb', line 17

def lemma
  @node.attr :lemma
end

#posObject



21
22
23
# File 'lib/opener/kaf/term.rb', line 21

def pos
  @node.attr :pos
end

#setPolarity(attrs, polarity_pos) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/opener/kaf/term.rb', line 25

def setPolarity attrs, polarity_pos
  #In case there is no pos info, we use the polarityPos
  @node[:pos] = polarity_pos if !pos and polarity_pos

  sentiment = @node.add_child('<sentiment/>')
  sentiment.attr attrs
end