主要针对英文文本做出词频计算,因为英文是用空格作为词语分割的。中文需要用到分词的库。
下面就用奥巴马的一片演讲做词频计算
1,分析的文本
speech_etxt = '''
My fellow citizens: I stand here today humbled by the task before us, grateful for the trust you've bestowed, mindful of the sacrifices borne by our ancestors.
I thank President Bush for his service to our nation -- (applause) -- as well as the generosity and cooperation he has shown throughout this transition.
Forty-four Americans have now taken the presidential oath. The words have been spoken during rising tides of prosperity and the still waters of peace. Yet, every so often, the oath is taken amidst gathering clouds and raging storms. At these moments, America has carried on not simply because of the skill or vision of those in high office, but because we, the people, have remained faithful to the ideals of our forebears and true to our founding documents.
So it has
更多推荐
利用python进行词频统计_利用python做词频计算(word-count)
发布评论