讲解:programming、Python, C/C++,Java、dataSPSS|Java

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

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • By clicking to agree to this Schedule 2, which is hereby ...
    qaz0622阅读 5,407评论 0 2
  • 本文转载自知乎 作者:季子乌 笔记版权归笔记作者所有 其中英文语句取自:英语流利说-懂你英语 ——————————...
    Danny_Edward阅读 44,012评论 4 38
  • 一直在思考,人与人之间的相处过程。有让你感动到流泪的,也有心酸到让你无法言语的,更有刻薄的让你脸面扫地,还有冷漠到...
    熏莉阅读 1,274评论 0 0
  • 以往,一个人的午餐,就是吃昨晚的剩菜剩饭居多。 没有昨晚剩下的饭菜时,就烤两篇吐司,再加一片起司,冒充午饭凑合一下...
    心怡在紐村阅读 1,045评论 0 1
  • P109-150 11、关于知识的知识 1、笔记:“元认知”是学习行为的组成部分,当元认知不能自动或内隐地完成时,...
    cae6f12ddc62阅读 2,726评论 0 0

友情链接更多精彩内容