首页 > 其他 > 详细

词频统计

时间:2018-03-26 11:53:58      阅读:188      评论:0      收藏:0      [点我收藏+]
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

 

词频统计

原文:https://www.cnblogs.com/linbolinbo/p/8649841.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!