class LLT::Review::Treebank::Parser::NokogiriHandler
Public Instance Methods
characters(string)
click to toggle source
# File lib/llt/review/treebank/parser/nokogiri_handler.rb, line 38 def characters(string) if @in_annotator parse_annotator_values(string) end end
end_element(name, attrs = [])
click to toggle source
# File lib/llt/review/treebank/parser/nokogiri_handler.rb, line 28 def end_element(name, attrs = []) if name == 'annotator' @in_annotator = false end if @in_annotator set_annotator_variable(name, false) end end
parse(data)
click to toggle source
# File lib/llt/review/treebank/parser/nokogiri_handler.rb, line 11 def parse(data) Nokogiri::XML::SAX::Parser.new(self).parse(data) end
start_element(name, attrs = [])
click to toggle source
# File lib/llt/review/treebank/parser/nokogiri_handler.rb, line 15 def start_element(name, attrs = []) case name when 'word' then register_word(attrs) when 'sentence' then register_sentence(first_val(attrs)) when 'treebank' then register_treebank_attrs(attrs) when 'annotator' then @in_annotator = true end if @in_annotator set_annotator_variable(name, true) end end
Private Instance Methods
register_treebank_attrs(attrs)
click to toggle source
# File lib/llt/review/treebank/parser/nokogiri_handler.rb, line 51 def register_treebank_attrs(attrs) hsh = Hash[attrs] register_language(hsh['xml:lang']) register_format(hsh['format']) end
register_word(attrs)
click to toggle source
Calls superclass method
LLT::Review::Helpers::Parsing::Helper#register_word
# File lib/llt/review/treebank/parser/nokogiri_handler.rb, line 46 def register_word(attrs) super(attrs.shift.last) # need to shift, we don't want the id in the next step attrs.each { |k, v| @word.send("#{k}=", v) } end