首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带quanteda的茎

带quanteda的茎
EN

Stack Overflow用户
提问于 2019-02-04 06:46:13
回答 1查看 583关注 0票数 0

我使用以下命令使用quanteda进行词干分析

代码语言:javascript
复制
myDfm <- dfm(tokens_remove(tokens(df2, remove_punct = TRUE, stem = TRUE, remove_numbers = TRUE, remove_symbols = TRUE), stopwords(source = "smart")), 
                          ngrams = c(1,2))

然而,我在最后收到以下警告:

代码语言:javascript
复制
Warning message:
Argument stem not used. 

是否有任何不同的选项来使用quanteda实现词干分析

EN

回答 1

Stack Overflow用户

发布于 2019-02-04 07:25:50

是的,你想要tokens_wordstem()。在您的示例中,您将stem = TRUE提供给tokens()参数,而不是dfm()调用。tokens()没有将stem作为参数(如警告所述)。

为了清楚起见,我建议使用管道操作符%>%来更清楚地查看操作的顺序。

代码语言:javascript
复制
library("quanteda")
## Package version: 1.4.0
## Parallel computing: 2 of 12 threads used.
## See https://quanteda.io for tutorials and examples.
## 
## Attaching package: 'quanteda'
## The following object is masked from 'package:utils':
## 
##     View

df2 <- data_char_sampletext
quanteda_options(verbose = TRUE)

df2 %>%
  tokens(remove_punct = TRUE, remove_numbers = TRUE, remove_symbols = TRUE) %>%
  tokens_remove(stopwords(source = "smart")) %>%
  tokens_wordstem() %>%
  tokens_ngrams(n = c(1, 2)) %>%
  dfm()
## removed 0 features
## 
## removed 72 features
## Creating a dfm from a tokens input...
##    ... lowercasing
##    ... found 1 document, 375 features
##    ... created a 1 x 375 sparse dfm
##    ... complete. 
## Elapsed time: 0.038 seconds.
## Document-feature matrix of: 1 document, 375 features (0.0% sparse).
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54508350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档