module Coreference
Public Instance Methods
coref_mention(input, with_pos_tags=nil)
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 48 def coref_mention input, with_pos_tags=nil coref_blob = Hash[ input .children .select{|v| v.class == Nokogiri::XML::Element} .map{|v| [v.name.to_sym, to_i_based_on_field_name(v.text, v.name)]} ] with_pos_tags ? add_pos_tags_to(coref_blob) : coref_blob end
coref_mention_nok_to_blob(input, add_representative_flag=nil, with_pos_tags=nil)
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 39 def coref_mention_nok_to_blob input, add_representative_flag=nil, with_pos_tags=nil add_representative_flag ? with_representative_flag( coref_mention(input, with_pos_tags), input ) : coref_mention(input, with_pos_tags) end
coref_mentions_nok_to_blob(input, with_pos_tags=nil)
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 30 def coref_mentions_nok_to_blob input, with_pos_tags=nil input .children .select{|m| m.name == 'mention' } .map{|m| coref_mention_nok_to_blob(m, true, with_pos_tags)} end
coref_nok_to_blob(input, with_pos_tags=nil)
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 10 def coref_nok_to_blob input, with_pos_tags=nil { representative: coref_representative_nok_to_blob(input, with_pos_tags), mentions: coref_mentions_nok_to_blob(input, with_pos_tags) } end
coref_representative_nok_to_blob(input, with_pos_tags=nil)
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 17 def coref_representative_nok_to_blob input, with_pos_tags=nil coref_mention_nok_to_blob( input .children .select{|m| m.name == 'mention' && m.attributes['representative'] } .first, false, with_pos_tags ) end
coreferences()
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 2 def coreferences self.xpath("//coreference//coreference").map{|c| coref_nok_to_blob(c)} end
coreferences_with_pos()
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 6 def coreferences_with_pos self.xpath("//coreference//coreference").map{|c| coref_nok_to_blob(c, true)} end
to_i_based_on_field_name(input, field_name)
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 63 def to_i_based_on_field_name input, field_name field_name == 'text' ? input : input.to_i end
with_representative_flag(input, parent)
click to toggle source
# File lib/stanford_corenlp_xml_adapter/coreference.rb, line 58 def with_representative_flag input, parent parent.name == 'mention' && parent.attributes['representative'] ? input.merge({ representative: true }) : input end