tm_map:可以将removewords功能与我自己的停用词一起注册为txt文件吗?

问题描述 投票:0回答:1

我正在使用R tm包对一个Facebook组进行文本分析,并发现removewords功能不适用于我。我试图将法语停用词与我自己的停用词结合使用,但它们仍在出现。因此,我用自己的列表创建了一个名为“ french.txt”的文件,如以下命令所示:

nom_fichier <- "Analyse textuelle/french.txt"
my_stop_words <- readLines(nom_fichier, encoding="UTF-8")

这里是用于文本挖掘的数据:

text <- readLines(groupe_fb_ief, encoding="UTF-8")```
docs <- Corpus(VectorSource(text))
inspect(docs) 

这里是tm_map命令:

docs <- tm_map(docs, tolower)

docs <- tm_map(docs, stripWhitespace)

docs <- tm_map(docs, removePunctuation)

docs <- tm_map(docs, removeNumbers)

docs <- tm_map(docs, removeWords, my_stop_words)

应用那个,它仍然没有用,我不明白为什么。我什至尝试更改命令的顺序,但没有结果。

你有什么主意吗?是否可以在R中更改法语停用词?此列表位于何处?

谢谢!

r tm stop-words
1个回答
0
投票

而不是通常使用anti_join()来删除所有停用词,而不是使用RemoveWords。

anti_join(docs,my_stop_words, by = "word")

希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.