Accessing Stanford Core NLP Coreference Chain output in Ruby -
i trying use stanford core nlp :coref_chain
list of entity mentions out of text. when run code:
text = 'angela merkel met nicolas sarkozy on january 25th in ' + 'berlin discuss new austerity package. sarkozy ' + 'looked pleased, merkel dismayed.' pipeline = stanfordcorenlp.load(:tokenize, :ssplit, :pos, :lemma, :parse, :ner, :dcoref) text = stanfordcorenlp::annotation.new(text) pipeline.annotate(text) puts text.get(:coref_chain)
i output:
{1=chain1-["angela merkel" in sentence 1, "merkel" in sentence 2], 3=chain3-["january 25th" in sentence 1], 4=chain4-["berlin" in sentence 1], 5=chain5-["nicolas sarkozy on january 25th" in sentence 1, "sarkozy" in sentence 2], 6=chain6-["a new austerity package" in sentence 1]}
is hash? according documentation on stanford site, should able access these values through attribute names no combination has worked me. in fact, adding other to_s
yields "no method found" error.
does 1 know how names out of this? "angela merkel" example? in best case scenario, start, end , heads well.
look @ the example code using gem. have loop on returned value of text.get
:
text.get(:sentences).each |sentence|
you can loop on sentences returned , extract further information.
what think hash isn't hash. it's string representation of internal structure they're using created when told puts
, similar inspect
return.
Comments
Post a Comment