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è)代寫(xiě)猖腕、Python, C/C++,Java程序語(yǔ)言作業(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)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門(mén)溉苛,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)镜廉,“玉大人,你說(shuō)我怎么就攤上這事愚战〗课ǎ” “怎么了齐遵?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)塔插。 經(jīng)常有香客問(wèn)我梗摇,道長(zhǎng),這世上最難降的妖魔是什么佑淀? 我笑而不...
- 正文 為了忘掉前任留美,我火速辦了婚禮彰檬,結(jié)果婚禮上伸刃,老公的妹妹穿的比我還像新娘。我一直安慰自己逢倍,他們只是感情好捧颅,可當(dāng)我...
- 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著较雕,像睡著了一般碉哑。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上亮蒋,一...
- 那天扣典,我揣著相機(jī)與錄音,去河邊找鬼慎玖。 笑死贮尖,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的趁怔。 我是一名探鬼主播湿硝,決...
- 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼润努!你這毒婦竟也來(lái)了关斜?” 一聲冷哼從身側(cè)響起,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤铺浇,失蹤者是張志新(化名)和其女友劉穎痢畜,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體鳍侣,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡裁着,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了拱她。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片二驰。...
- 正文 年R本政府宣布矗积,位于F島的核電站全肮,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏棘捣。R本人自食惡果不足惜辜腺,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望乍恐。 院中可真熱鬧评疗,春花似錦、人聲如沸茵烈。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)呜投。三九已至加匈,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間仑荐,已是汗流浹背雕拼。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像男图,于是被迫代替她去往敵國(guó)和親示姿。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 5) ( programming) Write and submit a program written in P...
- By clicking to agree to this Schedule 2, which is hereby ...
- 本文轉(zhuǎn)載自知乎 作者:季子烏 筆記版權(quán)歸筆記作者所有 其中英文語(yǔ)句取自:英語(yǔ)流利說(shuō)-懂你英語(yǔ) ——————————...
- 當(dāng)你發(fā)現(xiàn)你與周?chē)娜烁窀癫蝗氲臅r(shí)候,不是鶴立雞群而是遠(yuǎn)離這群雞谍憔。 之前看到過(guò)這樣一句話啊匪蝙,俄羅斯方塊告訴...