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

词频统计

时间:2018-03-26 12:31:18      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:last   rds   har   .exe   lis   was   news   word   ict   

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

 

词频统计

标签:last   rds   har   .exe   lis   was   news   word   ict   

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

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