词频统计

Posted 110林博

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了词频统计相关的知识,希望对你有一定的参考价值。

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

 

以上是关于词频统计的主要内容,如果未能解决你的问题,请参考以下文章

Spark编程实战-词频统计

Spark编程实战-词频统计

词频统计代码任务总结

词频统计2

词频统计

jieba库分词词频统计