5) ( programming) Write and submit a program written in Perl, Python, C,C++, or Java, named a4q5.pl, a4q5.py, a4q5.c, a4q5.cc, or a4q5.java, which verifies one or morebracketed parse trees, and check that their grammar is the Chomsky Normal Form grammar.The program must read the standard input. It expects one or more parse trees in the inputand the program should process them. The parse trees are in the format discussed in theclass. You should also assume that all non-terminals consist of uppercase letters andterminals consist of uppercase letters, lowercase letters, and digits, and not necessarily all ofthem. In other words, terminals satisfy the regular expression /[A-Za-z0-9]+/. Each parse treewill start with open parenthesis ‘(’, and there can be spaces between parentheses, terminals,and non-terminals.If the trees are all valid and their grammar is in Chomsky Normprogramming作业代写、Python, C/C++,Java程序语言作业调试、代做data课程作业 代做SPSSal Form, the program mustprint the following line:Valid CNF trees.(Always finish a line with a new-line character.) Forexample, the following input:(S (NP dogs) (VP run)) (S nothing)should produce output:Valid CNF trees.If the trees do not follow specifications, are not proper trees, or not in Chomsky NormalForm, then the program must print the line:Not valid CNF trees.For example, the following input should produce this message:(S (NP dogs) (VP run) (ADV fast))As a more complex example, the following input should be accepted as ‘Valid CNF trees’:(S (WNP (WDT What)(NN courses))(VP (BE are)(VP (VBN offered)(PP (IN in)(NN fall)))))(S (WNP Who)2(VP (VBZ teaches)(NP (NN CSCI)(NN 1100))))(S (WNP (WDT (WRB How) (JJ many))(NN students))(VP (BE are)(VB (VBG taking)(NP (NN CSCI)(NN 1108)))))转自:http://www.6daixie.com/contents/3/5075.html
讲解:programming、Python, C/C++,Java、dataSPSS|Java
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- By clicking to agree to this Schedule 2, which is hereby ...
- 本文转载自知乎 作者:季子乌 笔记版权归笔记作者所有 其中英文语句取自:英语流利说-懂你英语 ——————————...