1. 程式人生 > >英文詞頻統計

英文詞頻統計

top 自己的 phi rust dom 分享 operation color reason

str=‘‘‘In his speech at the closing session of this year‘s National People‘s Congress, Chinese President Xi Jinping reiterated the two centenary goals and emphasized a vision of a "Community of Shared Future for Mankind". The aspects of this vision have global meaning, and observers have taken great interest in this philosophy within the context of China‘s internal and external circumstances.

With confidence and a pragmatic vision for the nation, Xi called on all efforts to tackle challenges and realize the Chinese Dream of national rejuvenation. He took the historic example of four great Chinese inventions — paper, printing, the compass and gunpowder — and encourage all NPC members to work hard for new achievements in a new era to build a strong, modern, socialist nation and also contribute to the peace, stability and development of the world. In the presence of more than 2,900 lawmakers, Xi asserted the Chinese people are striving for the goal of the building of a moderately prosperous society in all respects by 2020 and to tackle the unprecedented challenges ahead through a huge united effort, hard work and scientific vision.

In this speech Xi, also General Secretary of the CPC Central Committee, outlined his vision for the world community, too. He assured us there is no reason to see China as a threat, as proved by China‘s efforts since its reform and opening-up policy started in 1978. Some Western scholars still try to use the phrase "China threat" and give pressure to their leadership not to accept China‘s rise. But history has clearly shown today‘s global challenges were created by the domineering approach of the western countries. With China‘s development and relevant stake in the international arena, developing world-seeking contribution of China for more a equal and balanced international world order.

On the issue of building a favorable environment for world peace and development, Xi‘s speech has actually given a tangible overview for building a community of shared future for mankind. From Asia to Africa and Europe to Latin America, China‘s partnerships are increasing in new dimensions under Xi‘s guidance The last five years have shown China can maintain a harmonious relationship with the rest of the world based on mutual trust and win-win cooperation. China‘s contribution to the United Nations peacekeeping mission is highly admired by UN leadership and the world community.

China‘s assistance to underdeveloped and developing countries has started to have positive effects for the political stability and economic prosperity of the recipient nations. This is one reason why many countries are attracted to the China-led Belt and Road Initiative and the Asian Infrastructure and Investment Bank. To seek resolution to international conflicts and disputes, Xi has always focused on comprehensive dialogue and negotiations between conflicted parties. China‘s approach to settling conflicts has demonstrated China wants peaceful resolution of any international conflict and urges all parties to contribute to peace. In his speech, Xi said China will continue to participate in reform and development of world governance as well as contribute more "Chinese wisdom, Chinese solutions and Chinese strength" to promote lasting peace and stability in the world.

China‘s domestic development will have direct impact on the global sphere. A country with a history of more than 5,000 years has a lot to contribute to the rest of the world when it comes to peace and development. There is no doubt the targeted centenary goals of the Chinese leadership will be fulfilled. A strong and prosperous China will be supportive of world peace and development. Now the rest of the world is watching the newly elected Chinese leadership for more comprehensive efforts in building mutual trust and understanding to create a safe, clean and harmonious world.
‘‘‘

#把標點符號用空格替換 str=str.replace(",","").replace(".","").replace("?","").replace("","").replace(":","").replace(","") str=str.lower() #將字符串轉小寫 str=str.split() #以空格劃分每個單詞 ls=list(str) #單詞列表 set=set(ls) #列表轉集合去重 list1=list(set) #再把集合轉成列表作為列表合並 list2=[] #建立個空列表,用來存放每個單詞出現的次數 for i in
set: list2.append(str.count(i)) #統計各單詞出現次數 dict=dict(zip(list1,list2)) #將單詞列表與對應頻數組成字典 #去掉一些沒意義的單詞 list3=[for,the,and,to,of,a,in,xi,on,have,is,by,than] for i in list3: del dict[i] dict2=sorted(dict.items(), key=lambda x: x[1], reverse=True) for i in range(10): #
輸出詞頻top10 print(dict2[i])

技術分享圖片

感覺這個題有挺多方法的,不知道自己的方法會不會太復雜了。

另外,其實這裏出現最高的詞匯應該是china,因為文章中出現的china‘s在去掉標點符號" ‘ "後就變成了chinas,但這裏沒有去處理這個問題

英文詞頻統計