firebase-cloud-messaging - quanteda 的 fcm 函数:选择窗口一侧的任何可能性
问题描述
quanteda::fcm(wiki_toks, context = "window", count = "weighted", window = 3)
现在上面的代码是在目标特征之前和之后选择 3 个单词。是否有可能设置窗口以选择目标特征的左侧?
谢谢您的帮助。
解决方案
您可以ordered = TRUE
在反转令牌后使用。所以:
library("quanteda")
## Package version: 3.0.0
## Unicode version: 10.0
## ICU version: 61.1
## Parallel computing: 12 of 12 threads used.
## See https://quanteda.io for tutorials and examples.
toks <- tokens(c("A D A C", "A B D E"))
fcm(toks, context = "window", window = 2, ordered = TRUE)
## Feature co-occurrence matrix of: 5 by 5 features.
## features
## features A D C B E
## A 1 2 1 1 0
## D 1 0 1 0 1
## C 0 0 0 0 0
## B 0 1 0 0 1
## E 0 0 0 0 0
fcm(as.tokens(lapply(toks, rev)),
context = "window", window = 2, ordered = TRUE
)
## Feature co-occurrence matrix of: 5 by 5 features.
## features
## features C A D E B
## C 0 1 1 0 0
## A 0 1 1 0 0
## D 0 2 0 0 1
## E 0 0 1 0 1
## B 0 1 0 0 0
由reprex 包于 2021-04-12 创建(v1.0.0)
推荐阅读
- java - 使用现有的 http 客户端进行 SOAP 调用
- material-ui - Material UI 样式最佳实践
- mysql - 连接一个单亲的两个子表,以检索数据 - MySQL
- sql - 使用(雪花)sql基于重叠时间戳组合记录
- javascript - 将带有 Google 图表和表格的 PHP 导出为 PDF
- angular - 如何根据 Angular 8 中的 Route 更改 html 布局?
- c++ - 检查反转数组是否与原始数组相同
- react-admin - 撤消列表中的软删除
- html - 修改父类的CSS
- swift - TPPDF:在 Table() 的同一单元格中添加多个带有文本内容的图像