我尝试在python (google-colaboratory)中使用波斯语的CountVectorizer()停用词。我不知道该如何将波斯语停用词作为函数的参数
例如,here是一个波斯语停用词列表,但我不知道如何将该列表提供给我的代码
vect = CountVectorizer(stop_words='persian', tokenizer = hazm.word_tokenize).fit(txt)
发布于 2020-03-13 14:16:10
您可以简单地将所引用的所有停用词放在python list中,然后将列表传递给CountVectorizer。例如:
persian_stop_words = ["در", "این"]
vect = CountVectorizer(stop_words=persian_stop_words)发布于 2021-05-10 14:17:45
您可以使用此开源存储库查找波斯语停用词的集合:
https://github.com/kharazi/persian-stopwords
要加载它们,只需将行复制并粘贴到单个文件中(由换行符分隔),然后将其命名为"stopwords.data“。然后,您可以将该文件加载到您的项目中,并将加载的文件作为CountVectorizer "stop_words“参数:
persian_stop_words = loadtxt('stopwords.dat', dtype=str, delimiter='\n')
vect = CountVectorizer(stop_words=persian_stop_words)https://stackoverflow.com/questions/55876456
复制相似问题