r - “是否有用于标记单词主题的 R 函数(文本分析)(例如:名词、形容词)?”
问题描述
我正在对情感分析进行文本挖掘。但是,当我对英文文章使用文本挖掘时,我遇到了一个问题。请问有没有类似jieba包的worker(type='tag')函数,但是在英文文本挖掘包中使用的函数(例如:tidytext)?
在下文中,它是我的代码的一部分。此代码用于中文文本挖掘。但是,我想以类似的方式进行英文文本挖掘。可以用什么函数代替worker(type="tag")的函数
library(jiebaRD)
library(jiebaR)
library(dplyr)
jieba <- worker(type="tag",user="C:/Users/User/Desktop/dict/bbb.txt",symbol = TRUE)
ecal<-function(str){
result <- jieba <= str
winfront <- 1L
count <- 1
winvalue <- c()
posvalue <- c()
negvalue <-c ()
pvalue <- 0L
nvalue <- 0L
ppcount <- 1
nncount <- 1
rheflag <- FALSE
for (i in 1:length(result)){
if(names(result[i])=="positive"){
#cat("find positive word:",result[i],"\n")
if(i==1)
winvalue[count] <- 1
else{
winvalue[count] <- 1
for (j in (i-1):winfront) {
if(!is.na((as.numeric(names(result[j])))))
winvalue[count] = winvalue[count]*as.numeric(names(result[j]))
else if(names(result[j])=="deny")
winvalue[count] = winvalue[count]*(-1)
else if(names(result[j])=="rhe")
rheflag <- TRUE
}
}
#cat("the value of window is:",winvalue[count],"\n")
count = count+1
winfront <- i+1
}
解决方案
您可以执行以下操作:
library(udpipe)
x <- udpipe("我拜訪了我在香港的朋友", "chinese")
请注意,如果您已经有中文分词器(例如 Jieba),您还可以使用 udpipe 使用 pos 标签丰富您的分词数据 - 请参阅https://cran.r-project 中的“我的文本数据已经分词”部分。 org/web/packages/udpipe/vignettes/udpipe-annotation.html#annotate_your_text
此处报告了基于通用依赖项的基于 Chinese-GSD 的模型的准确度统计信息:https ://github.com/jwijffels/udpipe.models.ud.2.3/blob/master/inst/udpipe-ud-2.3-181115/README 标记化不是最理想的,但是考虑到黄金标记化的 pos 标记在准确性方面非常好。
推荐阅读
- jmeter - JMeter 1 用户响应代码:非 HTTP 响应代码:java.net.ConnectionException 响应消息:非 HTTP 响应
- python - 使用卷积积分拟合指数衰减 -
- c++ - 将 DLL 添加到特定项目后出现 LNK2019 错误(通常工作正常)
- python - seasonal.seasonal_decompose 包中移动平均趋势的窗口长度是多少?
- c# - 在 DevExp 上更改 gridView 上的单元格数据
- cloudera-manager - Cloudera Manager [用尽可用的身份验证方法]
- c# - 如何正确清理 TcpListener,以避免“地址已在使用”错误?
- ios - 如何获取 N 个最近的项目,但使用 NSFetchRequest 按升序对它们进行排序
- html - 如何从中心用虚线连接圆圈?
- azure - 从 api 管理获取 Azure Key Vault 中的机密?