{"id":323,"date":"2016-04-21T16:30:36","date_gmt":"2016-04-21T14:30:36","guid":{"rendered":"http:\/\/yellingstone.info\/?p=323"},"modified":"2016-04-22T22:43:40","modified_gmt":"2016-04-22T20:43:40","slug":"%e6%94%b6%e9%9b%86%e4%b8%80%e7%af%87%e6%96%87%e7%ab%a0%e5%87%ba%e7%8e%b0%e7%9a%84%e6%89%80%e6%9c%89%e5%8a%a8%e8%af%8d%e8%af%8d%e5%b9%b2","status":"publish","type":"post","link":"http:\/\/yellingstone.info\/?p=323","title":{"rendered":"\u7edf\u8ba1\u6587\u7ae0\u91cc\u52a8\u8bcd\u8bcd\u5e72\u4f7f\u7528\u9891\u7387"},"content":{"rendered":"<p>\u60f3\u77e5\u9053\u54ea\u4e9b\u662f\u65af\u74e6\u5e0c\u91cc\u8bed\u4e2d\u51fa\u73b0\u9891\u7387\u6700\u9ad8\u7684\u52a8\u8bcd\u8bcd\u5e72\uff0c\u505a\u4e00\u4e2a<strong>\u6700\u5e38\u7528\u52a8\u8bcd\u8bcd\u5e72\u5217\u8868<\/strong>\u3002\u65b9\u6cd5\u662f\uff1a\u4e00\u4e2a\u8bcd\u4e00\u4e2a\u8bcd\u5730\u9605\u8bfb\u4e00\u7bc7\u6587\u7ae0\uff0c\u68c0\u6d4b\u8fd9\u4e2a\u8bcd\u662f\u5426\u662f\u52a8\u8bcd\u7684\u53d8\u5f62\uff08\u4e4b\u524d\u7684\u90e8\u5206\u662f\u5426\u7b26\u5408\u7279\u5b9a\u53d8\u5f62\u89c4\u5219\uff0c\u5728\u811a\u672c\u91cc\u9762\u88ab\u79f0\u4e3a pre-set\uff09\uff0c\u5982\u679c\u662f\u7684\u8bdd\u5c31\u653e\u8fdb\u4e00\u4e2a\u5b57\u5178\u91cc\u3002\u6700\u540e\u7edf\u8ba1\u4e00\u4e0b\u5b57\u5178\u91cc\u6700\u5e38\u51fa\u73b0\u7684\u90a3\u4e9b\u52a8\u8bcd\u8bcd\u5e72\u3002<\/p>\n<p>\u9700\u8981<a href=\"http:\/\/yellingstone.info\/?p=84\">\u52a8\u8bcd\u8bcd\u5e72\u7684\u5217\u8868<\/a>\u3002<\/p>\n<p>[code language=&#8221;python&#8221;]<br \/>\n# prepare the pre-set<br \/>\n# affirmative<br \/>\npre1=[&#8216;a&#8217;, &#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;]<br \/>\npre2=[&#8216;ka&#8217;, &#8216;ki&#8217;, &#8216;li&#8217;, &#8216;me&#8217;, &#8216;mesha&#8217;, &#8216;na&#8217;, &#8216;ta&#8217;]<br \/>\npre3=[&#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;mw&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;]<br \/>\npreS1=set()<br \/>\nfor p1 in pre1:<br \/>\n\tfor p2 in pre2:<br \/>\n\t\tpreS1.add(p1+p2)<br \/>\n\t\tfor p3 in pre3:<br \/>\n\t\t\tpreS1.add(p1+p2+p3)<br \/>\nfor p3 in pre3:<br \/>\n\tpreS1.add(&quot;hu&quot;)<br \/>\n\tpreS1.add(&quot;ku&quot;)<br \/>\n\tpreS1.add(&quot;hu&quot;+p3)<br \/>\n\tpreS1.add(&quot;ku&quot;+p3)<br \/>\n# negative present<br \/>\npre1=[&#8216;ha&#8217;, &#8216;hai&#8217;, &#8216;hai&#8217;, &#8216;haki&#8217;, &#8216;haku&#8217;, &#8216;haku&#8217;, &#8216;hali&#8217;, &#8216;ham&#8217;, &#8216;hamu&#8217;, &#8216;hapa&#8217;, &#8216;hatu&#8217;, &#8216;hau&#8217;, &#8216;havi&#8217;, &#8216;hawa&#8217;, &#8216;hawa&#8217;, &#8216;haya&#8217;, &#8216;hazi&#8217;, &#8216;hu&#8217;, &#8216;si&#8217;]<br \/>\npre2=[&#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;mw&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;]<br \/>\npreS2=set()<br \/>\nfor p1 in pre1:<br \/>\n\tpreS2.add(p1)<br \/>\n\tfor p2 in pre2:<br \/>\n\t\tpreS2.add(p1+p2)<br \/>\n# if subjuntive<br \/>\npre1=[&#8216;a&#8217;, &#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;]<br \/>\npre2=[&#8216;si&#8217;]<br \/>\npre3=[&#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;mw&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;]<br \/>\npreS3=set()<br \/>\nfor p1 in pre1:<br \/>\n\tpreS3.add(p1)<br \/>\n\tfor p2 in pre2:<br \/>\n\t\tpreS3.add(p1+p2)<br \/>\n\t\tfor p3 in pre3:<br \/>\n\t\t\tpreS3.add(p1+p3)<br \/>\n\t\t\tpreS3.add(p1+p2+p3)<\/p>\n<p># other negatives<br \/>\npre1=[&#8216;ha&#8217;, &#8216;hai&#8217;, &#8216;hai&#8217;, &#8216;haki&#8217;, &#8216;haku&#8217;, &#8216;haku&#8217;, &#8216;hali&#8217;, &#8216;ham&#8217;, &#8216;hamu&#8217;, &#8216;hapa&#8217;, &#8216;hatu&#8217;, &#8216;hau&#8217;, &#8216;havi&#8217;, &#8216;hawa&#8217;, &#8216;hawa&#8217;, &#8216;haya&#8217;, &#8216;hazi&#8217;, &#8216;hu&#8217;, &#8216;si&#8217;]<br \/>\npre2=[&#8216;ja&#8217;, &#8216;ku&#8217;, &#8216;ta&#8217;]<br \/>\npre3=[&#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;mw&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;]<br \/>\npreS4=set()<br \/>\nfor p1 in pre1:<br \/>\n\tfor p2 in pre2:<br \/>\n\t\tpreS4.add(p1+p2)<br \/>\n\t\tfor p3 in pre3:<br \/>\n\t\t\tpreS4.add(p1+p2+p3)<\/p>\n<p># prepare verb dictionary and the document<\/p>\n<p>verbD={}<\/p>\n<p>mydict=open(&quot;verb_stems.txt&quot;)<br \/>\ndictF=mydict.read()<br \/>\ndict=dictF.split()<\/p>\n<p>myfile=open(&quot;1.txt&quot;)<br \/>\nline=myfile.readline()<br \/>\n# junk words, which are most likely nouns or adverbs<br \/>\njunk=set([&#8216;hakimu&#8217;, &#8216;kijamii&#8217;, &#8216;kitaalamu&#8217;, &#8216;mbali&#8217;, &#8216;mradi&#8217;, &#8216;mshauri&#8217;, &#8216;mstaafu&#8217;, &#8216;mujibu&#8217;, &#8216;taasisi&#8217;, &#8216;unyonge&#8217;, &#8216;upande&#8217;, &#8216;ushahidi&#8217;, &#8216;utalii&#8217;, &#8216;utamaduni&#8217;, &#8216;vipande&#8217;, &#8216;wachache&#8217;, &#8216;wajibu&#8217;, &#8216;washauri&#8217;, &#8216;washiriki&#8217;, &#8216;wataalamu&#8217;, &#8216;watalii&#8217;])<br \/>\n# processing the words<\/p>\n<p>def ongeza():<br \/>\n\tif l not in verbD.keys():<br \/>\n\t\tverbD[l]=1<br \/>\n\telif l in verbD.keys():<br \/>\n\t\tverbD[l]+=1<br \/>\n\tprint l+&quot; in &quot;+word<\/p>\n<p>while line:<br \/>\n\twords=line.split()<br \/>\n\tfor word in words:<br \/>\n\t\tstop=1<br \/>\n\t\tword=word.strip(&quot;.,!?&quot;).lower()<br \/>\n\t\tif word not in junk:<br \/>\n\t\t\tfor l in dict:<br \/>\n\t\t\t\t# if the verb stem located as the end of the word, in affirmative<br \/>\n\t\t\t\tif word.rfind(l)&gt;0 and word.rfind(l)+len(l)==len(word) and word[:word.rfind(l)] in preS1 and stop:<br \/>\n\t\t\t\t\tongeza()<br \/>\n\t\t\t\t\tstop=0<br \/>\n\t\t\t\t# if the verb stem located as the end of the word, in negative present<br \/>\n\t\t\t\tlN=l[:-1]+l[-1].replace(&quot;a&quot;,&quot;i&quot;)<br \/>\n\t\t\t\tif word.rfind(lN)&gt;0 and word.rfind(lN)+len(lN)==len(word) and word[:word.rfind(lN)] in preS2 and stop:<br \/>\n\t\t\t\t\tongeza()<br \/>\n\t\t\t\t\tstop=0<br \/>\n\t\t\t\t# if subjunctive<br \/>\n\t\t\t\tlS=l[:-1]+l[-1].replace(&quot;a&quot;,&quot;e&quot;)<br \/>\n\t\t\t\tif word.rfind(lS)&gt;0 and word.rfind(lS)+len(lS)==len(word) and word[:word.rfind(lS)] in preS3 and stop:<br \/>\n\t\t\t\t\tongeza()<br \/>\n\t\t\t\t\tstop=0<br \/>\n\t\t\t\t# if the verb stem located as the end of the word, in negative<br \/>\n\t\t\t\tif word.rfind(l)&gt;0 and word.rfind(l)+len(l)==len(word) and word[:word.rfind(l)] in preS4 and stop:<br \/>\n\t\t\t\t\tongeza()<br \/>\n\t\t\t\t\tstop=0<br \/>\n\tline=myfile.readline()<br \/>\n#print verbD<br \/>\nfor key in sorted(verbD.keys()):<br \/>\n\tprint key+&quot;: &quot;+str(verbD[key])<br \/>\n[\/code]<\/p>\n<p>\u7ed3\u679c\uff08\u622a\u9009\uff09\uff1a<br \/>\n[code]<br \/>\nchoshwa: 3<br \/>\nchukua: 3<br \/>\ndaiwa: 2<br \/>\ndumu: 2<br \/>\neleza: 10<br \/>\nelezea: 6<br \/>\nendekeza: 1<br \/>\nendelea: 8<br \/>\nendeleza: 4<br \/>\nendesha: 2<br \/>\nepuka: 1<br \/>\nepusha: 1<br \/>\nfafanua: 1<br \/>\nfahamisha: 1<br \/>\nfahamu: 1<br \/>\nfaidika: 1<br \/>\nfanya: 7<br \/>\n[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u60f3\u77e5\u9053\u54ea\u4e9b\u662f\u65af\u74e6\u5e0c\u91cc\u8bed\u4e2d\u51fa\u73b0\u9891\u7387\u6700\u9ad8\u7684\u52a8\u8bcd\u8bcd\u5e72\uff0c\u505a\u4e00\u4e2a\u6700\u5e38\u7528\u52a8\u8bcd\u8bcd\u5e72\u5217\u8868\u3002\u65b9\u6cd5\u662f\uff1a\u4e00\u4e2a\u8bcd\u4e00\u4e2a\u8bcd\u5730\u9605\u8bfb\u4e00\u7bc7\u6587\u7ae0\uff0c\u68c0\u6d4b\u8fd9\u4e2a\u8bcd\u662f\u5426\u662f\u52a8\u8bcd\u7684\u53d8\u5f62\uff08\u4e4b\u524d\u7684\u90e8\u5206\u662f\u5426\u7b26\u5408\u7279\u5b9a\u53d8\u5f62\u89c4\u5219\uff0c\u5728\u811a\u672c\u91cc\u9762\u88ab\u79f0\u4e3a pre-set\uff09\uff0c\u5982\u679c\u662f\u7684\u8bdd\u5c31\u653e\u8fdb\u4e00\u4e2a\u5b57\u5178\u91cc\u3002\u6700\u540e\u7edf\u8ba1\u4e00\u4e0b\u5b57\u5178\u91cc\u6700\u5e38\u51fa\u73b0\u7684\u90a3\u4e9b\u52a8\u8bcd\u8bcd\u5e72\u3002 \u9700\u8981\u52a8\u8bcd\u8bcd\u5e72\u7684\u5217\u8868\u3002 [code language=&#8221;python&#8221;] # prepare the pre-set # affirmative pre1=[&#8216;a&#8217;, &#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;] pre2=[&#8216;ka&#8217;, &#8216;ki&#8217;, &#8216;li&#8217;, &#8216;me&#8217;, &#8216;mesha&#8217;, &#8216;na&#8217;, &#8216;ta&#8217;] pre3=[&#8216;i&#8217;, &#8216;ki&#8217;, &#8216;ku&#8217;, &#8216;li&#8217;, &#8216;m&#8217;, &#8216;mu&#8217;, &#8216;mw&#8217;, &#8216;ni&#8217;, &#8216;pa&#8217;, &#8216;tu&#8217;, &#8216;u&#8217;, &#8216;vi&#8217;, &#8216;wa&#8217;, &#8216;ya&#8217;, &#8216;zi&#8217;] preS1=set() for p1 in pre1: for p2 <a class=\"read-more\" href=\"http:\/\/yellingstone.info\/?p=323\">&hellip;&nbsp;<span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/yellingstone.info\/index.php?rest_route=\/wp\/v2\/posts\/323"}],"collection":[{"href":"http:\/\/yellingstone.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yellingstone.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yellingstone.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yellingstone.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=323"}],"version-history":[{"count":0,"href":"http:\/\/yellingstone.info\/index.php?rest_route=\/wp\/v2\/posts\/323\/revisions"}],"wp:attachment":[{"href":"http:\/\/yellingstone.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yellingstone.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yellingstone.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}