tree generation for rules in python

爱⌒轻易说出口 提交于 2019-12-13 03:58:40

问题


I would like to draw a tree like structure using Tkinter for the following data:

 S--->NP VGF NP VGNF
 NP--->N_NNP_O_M        
 VGF--->V_VM_VF     
 NP--->N_NNP_S_F        
 VGNF--->V_VM_VNF       

 V_VM_VF--->എത്തി   
 N_NNP_S_F--->സീതയെ 
 V_VM_VNF--->കാണാന്‍    
 N_NNP_O_M--->രാമൻ  

This is the CFG rules for a single sentence, it written in a file.

How can i view these rules in the form of tree in python? That is parse tree.

How can I draw the tree using Tkinter in GUI.

Any help or any hint will be very much appreciated.


回答1:


do you have a parser if yes.then you will get parsetree when running that parser.

i think you have grammer but no parser.. if yes ....then use parser generaters to make parser. to make parser you must give grammer to generaters...

and after getting parse tree.its easy to draw tree in gui. nltk is for natural language processing..




回答2:


yes .but its not clear that what type of data you have and which way must draw is you want only an image that looks like a tree. or is it draw with a widget if you need to draw that as an image use tkinter.canvas()### or use as widget tkinter.tree_view



来源:https://stackoverflow.com/questions/21571510/tree-generation-for-rules-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!