在文本分析中提取词干后没有得到正确的文本(瑞典语)
Not getting the right text after stemming in text analysis (Swedish)
在 R 中进行词干提取后,我无法获得正确的文本。
例如。 'papper' 应显示为 'papper',但显示为 'papp','projekt' 变为 'projek'。
因此生成的频率云显示了这些失去实际意义或变得难以理解的缩短版本。
我该怎么做才能摆脱这个问题?我正在使用最新版本的 snowball(0.6.0)。
R代码:
library(tm)
library(SnowballC)
text_example <- c("projekt", "papper", "arbete")
stem_doc <- stemDocument(text_example, language="sv")
stem_doc
Expected:
stem_doc
[1] "projekt" "papper" "arbete"
Actual:
stem_doc
[1] "projek" "papp" "arbet"
您在这里描述的实际上不是词干提取,而是所谓的词形还原(请参阅@Newl 的 link 了解不同之处)。
要获得正确的引理,您可以使用 R
包 UDPipe
,它是 UDPipe C++ library.
的包装器
这里是一个简单的例子,说明你会如何做你想做的事:
# install.packages("udpipe")
library(udpipe)
dl <- udpipe_download_model(language = "swedish-lines")
#> Downloading udpipe model from https://raw.githubusercontent.com/jwijffels/udpipe.models.ud.2.3/master/inst/udpipe-ud-2.3-181115/swedish-lines-ud-2.3-181115.udpipe to C:/Users/Johannes Gruber/AppData/Local/Temp/RtmpMhaF8L/reprex8e40d80ef3/swedish-lines-ud-2.3-181115.udpipe
udmodel_swed <- udpipe_load_model(file = dl$file_model)
text_example <- c("projekt", "papper", "arbete")
x <- udpipe_annotate(udmodel_swed, x = text_example)
x <- as.data.frame(x)
x$lemma
#> [1] "projekt" "papper" "arbete"
在 R 中进行词干提取后,我无法获得正确的文本。 例如。 'papper' 应显示为 'papper',但显示为 'papp','projekt' 变为 'projek'。
因此生成的频率云显示了这些失去实际意义或变得难以理解的缩短版本。
我该怎么做才能摆脱这个问题?我正在使用最新版本的 snowball(0.6.0)。
R代码:
library(tm)
library(SnowballC)
text_example <- c("projekt", "papper", "arbete")
stem_doc <- stemDocument(text_example, language="sv")
stem_doc
Expected:
stem_doc
[1] "projekt" "papper" "arbete"
Actual:
stem_doc
[1] "projek" "papp" "arbet"
您在这里描述的实际上不是词干提取,而是所谓的词形还原(请参阅@Newl 的 link 了解不同之处)。
要获得正确的引理,您可以使用 R
包 UDPipe
,它是 UDPipe C++ library.
这里是一个简单的例子,说明你会如何做你想做的事:
# install.packages("udpipe")
library(udpipe)
dl <- udpipe_download_model(language = "swedish-lines")
#> Downloading udpipe model from https://raw.githubusercontent.com/jwijffels/udpipe.models.ud.2.3/master/inst/udpipe-ud-2.3-181115/swedish-lines-ud-2.3-181115.udpipe to C:/Users/Johannes Gruber/AppData/Local/Temp/RtmpMhaF8L/reprex8e40d80ef3/swedish-lines-ud-2.3-181115.udpipe
udmodel_swed <- udpipe_load_model(file = dl$file_model)
text_example <- c("projekt", "papper", "arbete")
x <- udpipe_annotate(udmodel_swed, x = text_example)
x <- as.data.frame(x)
x$lemma
#> [1] "projekt" "papper" "arbete"