python中规则的树生成 [英] tree generation for rules in python

查看:261
本文介绍了python中规则的树生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Tkinter为以下数据绘制树状结构:

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--->രാമൻ  

这是单个句子的CFG规则,它写在文件中.

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

如何在python中以树的形式查看这些规则?那就是解析树.

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

如何在GUI中使用Tkinter绘制树.

How can I draw the tree using Tkinter in GUI.

非常感谢您的帮助或任何提示.

推荐答案

如果有解析器,那么运行该解析器时将获得解析树.

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...

并在解析tree.its之后很容易在gui中绘制树. nltk用于自然语言处理..

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

这篇关于python中规则的树生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆