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作業(yè)代寫、Python, C/C++,Java程序語言作業(yè)調(diào)試砰逻、代做data課程作業(yè) 代做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)))))轉(zhuǎn)自:http://www.6daixie.com/contents/3/5075.html
講解:programming、Python, C/C++,Java贡翘、dataSPSS|Java
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門坚冀,熙熙樓的掌柜王于貴愁眉苦臉地迎上來济赎,“玉大人,你說我怎么就攤上這事记某∷狙担” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵液南,是天一觀的道長壳猜。 經(jīng)常有香客問我,道長滑凉,這世上最難降的妖魔是什么蓖谢? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮譬涡,結(jié)果婚禮上闪幽,老公的妹妹穿的比我還像新娘。我一直安慰自己涡匀,他們只是感情好盯腌,可當(dāng)我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著陨瘩,像睡著了一般腕够。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上舌劳,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼撵割!你這毒婦竟也來了贿堰?” 一聲冷哼從身側(cè)響起,我...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 年R本政府宣布楞黄,位于F島的核電站抡驼,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏致盟。R本人自食惡果不足惜碎税,卻給世界環(huán)境...
- 文/蒙蒙 一馏锡、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧杯道,春花似錦匪煌、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽昧港。三九已至擎椰,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間创肥,已是汗流浹背达舒。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- By clicking to agree to this Schedule 2, which is hereby ...
- 本文轉(zhuǎn)載自知乎 作者:季子烏 筆記版權(quán)歸筆記作者所有 其中英文語句取自:英語流利說-懂你英語 ——————————...
- P109-150 11愁憔、關(guān)于知識的知識 1、筆記:“元認(rèn)知”是學(xué)習(xí)行為的組成部分孽拷,當(dāng)元認(rèn)知不能自動或內(nèi)隱地完成時惩淳,...