def runmytfidf(completeComment, topNumber):
commentList = []
#preprocessing the comments
for i in range(0,10):
commentList.append(tb(preprocessing(completeComment[i])))
returnList=[]
#Obtaing the Top Key words for all the pages
for i, page in enumerate(commentList):
scores = {word: tfidf(word, page, commentList) for word in page.words}
sorted_words = sorted(scores.items(), key=lambda x: x[1], reverse=True)
topWords=[]
for word, score in sorted_words[:topNumber]:
topWords.append(word)
returnList.append(topWords)
return returnList
Mytfidf.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录