Mytfidf.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:NLP-Keyword-Extraction-Ensemble-Method 作者: Ashwin-Ravi 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号