词频统计

1
#-*- coding:UTF-8 -*-
# -*- author:Duym -*-



wordList=news.lower().split()
for w in wordList:
    print(w)


the
area
of
green
was
reducing
in
the
last
decades

2
 




sep=''',."?!:'''
for c in sep:
  news=news.replace(c,'')

wordList=news.lower().split()
wordDict={}
wordSet=set(wordList)
for w in wordSet:
    wordDict[w]=wordList.count(w)
for w in wordSet:
    print(w)


C:UsersAdministratorPycharmProjectsdvenvScriptspython.exe C:/Users/Administrator/PycharmProjects/bd/gzcc.py
giant
part
then
government
return
lost
protect
down


3

sep=''',."?!:'''
for c in sep:
  news=news.replace(c,'')

wordList=news.lower().split()
wordDict={}

wordSet=set(wordList)
for w in wordSet:
    wordDict[w]=wordList.count(w)

for w in wordSet:


    print(w,wordDict[w])

day 2
main 1
conservation 1
last 1
only 1
such 1
a 1
lost 2
原文地址:https://www.cnblogs.com/linbolinbo/p/8649841.html