问题描述
我需要在其他文本上应用RAKE算法,但它只给我最后一个文本的关键字。您能帮我解决这个问题吗?
这是我的代码:
from rake_nltk import Rake
stop_dir = "SmartStoplist.txt"
rake_object = RAKE.Rake(stop_dir)
text1 = " Hello I am here"
text2 = " This is second text"
alltext = [ text1,text2]
topnumkey = 10
m = len(alltext)
t = ['' for i in range(topnumkey)]
topwords = [ t for j in range(m)]
for i in range(m):
text = alltext[i]
r= Rake()
r.extract_keywords_from_text(text)
keywords = r.get_ranked_phrases()
for j in range(topnumkey):
topwords[i][j] = keywords[j]
print(topwords)
没有错误,只是找到了最后一个文本关键字,并在我的列表中重复了该关键字。 有什么办法解决这个问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)