def extract_keyword(self):
sents = []
comm_list = self.dao.get_hotel_comments()
# ???????????????
for comm in comm_list:
sents.extend(normal.get_sentences(comm[2]))
print "length of sentences:%d"%len(sents)
# ??????????
pos_sents = []
for sent in sents:
pos_sents.append(pseg.cut(sent))
print "length of pos_sents:%d"%len(pos_sents)
# ?????,?????
print "counting"
noun_dict = {}
for pos_sent in pos_sents:
for key,type in pos_sent:
if type == "n":
if key not in noun_dict:
noun_dict[key] = 1
else:
noun_dict[key] = noun_dict[key] + 1
a = sorted(noun_dict.iteritems(),key=lambda asd:asd[1],reverse=True)
return a
KeywordsHandler.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录