词频统计

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:\Users\Administrator\PycharmProjects\bd\venv\Scripts\python.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

 

posted @ 2018-03-26 11:36  110林博  阅读(118)  评论(0编辑  收藏  举报