码迷,mamicode.com
首页 > 其他好文 > 详细

英文词频统计

时间:2018-03-22 01:38:01      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:输出   resid   自己   lis   zed   modern   print   moni   operation   

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,但这里没有去处理这个问题

英文词频统计

标签:输出   resid   自己   lis   zed   modern   print   moni   operation   

原文地址:https://www.cnblogs.com/1996-yxl/p/8620744.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!