在 python 中获取停用词列表时出现 Rake 错误
Rake error while getting stop words list in python
我正在运行宁以下代码
from rake_nltk import rake
import operator
stoppath = 'data/stoplists/SmartStoplist.txt'
rake_object = rake.Rake("SmartStopList.txt",5,3,2)
但是当我 运行 最后一行时,我得到以下错误
rake_object = rake.Rake("SmartStopList.txt",5,3,2)
Traceback (most recent call last):
File "<ipython-input-12-595e49e89adb>", line 1, in <module>
rake_object = rake.Rake("SmartStopList.txt",5,3,2)
File "C:\Users\kris\Anaconda3\lib\site-packages\rake_nltk\rake.py", line 64, in __init__
self.to_ignore = set(chain(self.stopwords, self.punctuations))
TypeError: 'int' object is not iterable
我不确定为什么会出现此错误。同样需要帮助
看看 __init__
def __init__(
self,
stopwords=None,
punctuations=None,
language="english",
ranking_metric=Metric.DEGREE_TO_FREQUENCY_RATIO,
max_length=100000,
min_length=1,
)
5 将转到 punctuations
参数,它应该是一个列表,而不是 ranking_metric
。使用参数名称
rake_object = rake.Rake("SmartStopList.txt", ranking_metric=5, max_length=3, min_length=2)
顺便说一句stopwords
也应该是一个列表,你发送的是字符串。
我正在运行宁以下代码
from rake_nltk import rake
import operator
stoppath = 'data/stoplists/SmartStoplist.txt'
rake_object = rake.Rake("SmartStopList.txt",5,3,2)
但是当我 运行 最后一行时,我得到以下错误
rake_object = rake.Rake("SmartStopList.txt",5,3,2)
Traceback (most recent call last):
File "<ipython-input-12-595e49e89adb>", line 1, in <module>
rake_object = rake.Rake("SmartStopList.txt",5,3,2)
File "C:\Users\kris\Anaconda3\lib\site-packages\rake_nltk\rake.py", line 64, in __init__
self.to_ignore = set(chain(self.stopwords, self.punctuations))
TypeError: 'int' object is not iterable
我不确定为什么会出现此错误。同样需要帮助
看看 __init__
def __init__(
self,
stopwords=None,
punctuations=None,
language="english",
ranking_metric=Metric.DEGREE_TO_FREQUENCY_RATIO,
max_length=100000,
min_length=1,
)
5 将转到 punctuations
参数,它应该是一个列表,而不是 ranking_metric
。使用参数名称
rake_object = rake.Rake("SmartStopList.txt", ranking_metric=5, max_length=3, min_length=2)
顺便说一句stopwords
也应该是一个列表,你发送的是字符串。