Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中使用RAKE提取关键字_Python_Rake - Fatal编程技术网

如何在python中使用RAKE提取关键字

如何在python中使用RAKE提取关键字,python,rake,Python,Rake,我已经实现了这段代码,但它不会在屏幕上打印任何内容 from rake_nltk import Rake r = Rake() # Uses stopwords for english from NLTK, and all puntuation characters. #r = Rake(english) # To use it in a specific language supported by nltk. # If you want to provide your own set o

我已经实现了这段代码,但它不会在屏幕上打印任何内容

from rake_nltk import Rake

r = Rake() # Uses stopwords for english from NLTK, and all puntuation characters.

#r = Rake(english) # To use it in a specific language supported by nltk.

# If you want to provide your own set of stop words and punctuations to
# r = Rake(<list of stopwords>, <string of puntuations to ignore>)

print(r.extract_keywords_from_text('hello world'))

r.get_ranked_phrases() # To get keyword phrases ranked highest to lowest.
来自rake\u nltk导入rake
r=Rake()#使用NLTK中的英语stopwords和所有puntuation字符。
#r=Rake(英语)#在nltk支持的特定语言中使用它。
#如果您想为用户提供自己的一组停止词和标点符号
#r=耙(,)
打印(从文本(“hello world”)中提取关键字)
r、 get_ranked_phrases()#获取从最高到最低的关键字短语。
语句:print(r.extract_keywords_from_text('hello world'))将不打印任何内容,因为它只提取关键字。您需要打印第二行代码,如下所示: 打印(r.获得排名的短语())。以下内容可能会有所帮助:

from rake_nltk import Rake
from nltk.corpus import stopwords 
r = Rake() # Uses stopwords for english from NLTK, and all puntuation characters.Please note that "hello" is not included in the list of stopwords.

text='Hello World'
a=r.extract_keywords_from_text(text)
b=r.get_ranked_phrases()
c=r.get_ranked_phrases_with_scores()
print(b)
print(c)

output:['hello world']
[(4.0, 'hello world')]
我建议您也可以尝试使用包含多个字符串的文本。有关更多详细信息,请参阅。

语句:print(r.extract_keywords_from_text('hello world'))将不打印任何内容,因为它只提取关键字。您需要打印第二行代码,如下所示: 打印(r.获得排名的短语())。以下内容可能会有所帮助:

from rake_nltk import Rake
from nltk.corpus import stopwords 
r = Rake() # Uses stopwords for english from NLTK, and all puntuation characters.Please note that "hello" is not included in the list of stopwords.

text='Hello World'
a=r.extract_keywords_from_text(text)
b=r.get_ranked_phrases()
c=r.get_ranked_phrases_with_scores()
print(b)
print(c)

output:['hello world']
[(4.0, 'hello world')]
我建议您也可以尝试使用包含多个字符串的文本。有关更多详细信息,请参阅