python - How to find syntactic path between two words from CoNLL format dependency parse using NLTK's DependencyGraph data structure? -


i trying find syntactic path between 2 words in sentence. using nltk's dependencygraph. input dependency parse in conll format. here steps followed:

from nltk.parse.dependencygraph import dependencygraph

output = dependencygraph.load('input.conll')#input.conll dependency parse in conll format

i thinking can use nltk's dependencygraph.nx_graphto convert dependency nodes directed graph. ones have in directed graph form, can compute path between 2 given words. here code convert dependency nodes graph:

g = dependencygraph.nx_graph(output[0]) 

however, having followiing error:

valueerror                                traceback (most recent call last) 

<ipython-input-8-1e005d290586> in <module>() ----> 1 g = dependencygraph.nx_graph(output[0])

//anaconda/lib/python3.4/site-packages/nltk/parse/dependencygraph.py in nx_graph(self) 543 g = networkx.multidigraph() 544 g.add_nodes_from(nx_nodelist) --> 545 g.add_edges_from(nx_edgelist) 546 547 return g

//anaconda/lib/python3.4/site-packages/networkx/classes/multigraph.py in add_edges_from(self, ebunch, attr_dict, **attr) 346 datadict=keydict.get(key,{}) 347 datadict.update(attr_dict) --> 348 datadict.update(dd) 349 self.add_edge(u,v,key=key,attr_dict=datadict) 350

valueerror: dictionary update sequence element #0 has length 1; 2 required

i doing in python3 , nltk 3.2.4. suggestion welcome. thanks.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -