我想知道R的文本挖掘包是否有任何机会具有以下功能:
myCorpus <- Corpus(DirSource(<directory-contatining-textfiles>),control=...)
# add docs
myCorpus.addDocs(DirSource(<new-dir>),control=...)
Run Code Online (Sandbox Code Playgroud)
理想情况下,我想将其他文档合并到现有语料库中.
任何帮助表示赞赏
我希望使用WordNet从一组基本术语中寻找类似术语的集合.
例如,"劝阻"这个词- 潜在的同义词可能是:daunted, glum, deterred, pessimistic.
我还想确定潜在的双克,如; beat down, put off, caved in等等
如何使用Java或Python提取此信息?是否有任何托管的WordNet数据库/ Web界面可以进行此类查询?
谢谢!
想text在句子中分割出一个字符元素的向量.分裂标准有多种模式("and/ERT","/$").也有例外(:/$.,and/ERT then,./$. Smiley)自该模式.
尝试:匹配拆分应该的情况."^&*"在该位置插入一个不寻常的图案().strsplit具体模式
问题:我不知道如何正确处理异常.有明确的情况"^&*"应该消除异常模式()并在运行之前恢复原始文本strsplit.
码:
text <- c("This are faulty propositions one and/ERT two ,/$, which I want to split ./$. There are cases where I explicitly want and/ERT some where I don't want to split ./$. For example :/$. when there is an and/ERT then I don't want to split ./$. This is also one case where I …Run Code Online (Sandbox Code Playgroud) 我有一个包含一些字符串的文本语料库.在这些字符串中,有些是英文单词,有些是随机的,如VmsVKmGMY6eQE4eMI,每个字符串中的字符数没有限制.
有没有办法测试一个字符串是否是英文单词?我正在寻找一种能够完成这项工作的算法.这是Java,我宁愿不实现额外的字典.
我是R软件的新手
现在,使用"tm"包研究文本挖掘"
我有一个关于将文本映射到小写的问题
sms_raw<-read.csv(............)
sms_corpus<-Corpus(VectorSource(sms_raw$text))
sms_corpus<-Corpus(VectorSource(sms_raw$text))
tm_map(sms_corpus,content_transformer(tolower))
error:invalid multubytes string 1
Run Code Online (Sandbox Code Playgroud)
我以为我的csv文件可能不是utf-8所以我恢复为utf-8但它没有用.
我的操作系统是win8.1
有人解决这个问题请告诉我.
我试图在一篇名为"对LSA的介绍"的论文中复制一个例子: 对LSA的介绍
在示例中,他们具有以下术语 - 文档矩阵:
然后他们应用SVD并获得以下内容:
试图复制这个,我写了以下R代码:
library(lsa); library(tm)
d1 = "Human machine interface for ABC computer applications"
d2 = "A survey of user opinion of computer system response time"
d3 = "The EPS user interface management system"
d4 = "System and human system engineering testing of EPS"
d5 <- "Relation of user perceived response time to error measurement"
d6 <- "The generation of random, binary, ordered trees"
d7 <- "The intersection graph of paths in trees"
d8 <- "Graph …Run Code Online (Sandbox Code Playgroud) 我已经看过这里发布的其他类似问题(像这样),但问题仍然存在.
我有一个文本数据的数据框,我需要阻止它.因此,我将其转换为语料库,然后将其转换为词干,然后完成词干中的单词,然后尝试将文本数据框作为输出.
myCorpus <- Corpus(VectorSource(textDf$text))
myCorpus <- tm_map(myCorpus, removeWords, stopwords('english'))
myCorpus <- tm_map(myCorpus, content_transformer(tolower))
myCorpus <- tm_map(myCorpus, removePunctuation)
dictCorpus <- myCorpus
myCorpus <- tm_map(myCorpus, stemDocument)
myCorpus <- tm_map(myCorpus, stemCompletion, dictionary=dictCorpus)
Run Code Online (Sandbox Code Playgroud)
现在我正试图从这个语料库中获取一个数据帧,所以我尝试了以下命令.
dataframe<-data.frame(text=unlist(sapply(myCorpus, '[', "content")),
stringsAsFactors=F)
和
dataframe<-data.frame(text=unlist(sapply(myCorpus,[)), stringsAsFactors=F)
并且
dataframe <-
data.frame(id=sapply(corpus, meta, "id"),
text=unlist(lapply(sapply(corpus, '[', "content"),paste,collapse="\n")),
stringsAsFactors=FALSE)
Run Code Online (Sandbox Code Playgroud)
从这个链接
所有这些都会产生以下错误:
Error in UseMethod("meta", x) :
no applicable method for 'meta' applied to an object of class "character"
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
我正在进行一些文本挖掘(PCA,HC,K-Means),到目前为止,我已经成功地编写了一切.但是,我想解决一个小缺陷.
当我试图阻止我的语料库时,它不能正常工作,因为有不同的词语具有相同的基础,而这些词语没有以正确的方式识别.这些是我特别感兴趣的词(它是西班牙语,意思是"孩子"或相关):
niñera, niños, niñas, niña, niño
Run Code Online (Sandbox Code Playgroud)
但是当我运行代码时,我发现这些单词仍然是相同的,除了
niña, niño --> niñ
Run Code Online (Sandbox Code Playgroud)
但另一方保持不变,所以我最终只是为了niña/niño,而不是其他人.
这是我创建语料库的代码:
corp <- Corpus(DataframeSource(data.frame(x$service_name)))
docs <- tm_map(corp, removePunctuation)
docs <- tm_map(docs, removeNumbers)
docs <- tm_map(docs, tolower)
docs <- tm_map(docs, removeWords, stopwords("spanish"))
docs <- tm_map(docs, stemDocument, language = "spanish")
docs <- tm_map(docs, PlainTextDocument)
dtm <- DocumentTermMatrix(docs)
dtm
Run Code Online (Sandbox Code Playgroud)
我真的很感激一些建议!谢谢
如何在Python中计算字符串的Levenshtein距离矩阵
str1 str2 str3 str4 ... strn
str1 0.8 0.4 0.6 0.1 ... 0.2
str2 0.4 0.7 0.5 0.1 ... 0.1
str3 0.6 0.5 0.6 0.1 ... 0.1
str4 0.1 0.1 0.1 0.5 ... 0.6
. . . . . ... .
. . . . . ... .
. . . . . ... .
strn 0.2 0.1 0.1 0.6 ... 0.7
Run Code Online (Sandbox Code Playgroud)
使用Ditance函数,我们可以计算2个单词之间的距离。但是这里有1个包含n个字符串的列表。我想计算距离矩阵,然后再对单词进行聚类。
python string machine-learning text-mining levenshtein-distance
我的adist函数有问题。基本上,我使用的是RDocumentation的示例。
attr(adist(c("kitten", "sitting"), counts = TRUE), "trafos") here
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行时,又增加了一个字
attr(adist(c("kitten", "sitting", "hi"), counts = TRUE), "trafos")
Run Code Online (Sandbox Code Playgroud)
我正在取得这些结果:
[,1] [,2] [,3]
[1,] "MMMMMM" "SMMMSMI" "SMDDDDI"
[2,] "SMMMSMD" "MMMMMMM" "SDDDMDD"
[3,] "SMIIIID" "SIIIMII" "MMI"
Run Code Online (Sandbox Code Playgroud)
在第三列的第三行中,我正在使用MMI,但我无法理解为什么是同一单词“ hi”。因此必须是MM。(匹配,匹配且无插入)
参考:https : //www.rdocumentation.org/packages/utils/versions/3.6.0/topics/adist
我正在使用另一个示例:
test <- c('x','hi', 'y','x')
attr(adist(test, y=NULL , counts = TRUE), "trafos")
Run Code Online (Sandbox Code Playgroud)
我正在取得这些结果。但是至少对角线需要为M,因为同一个单词。
[,1] [,2] [,3] [,4]
[1,] "M" "SI" "SI" "MI"
[2,] "SD" "MM" "SD" "SD"
[3,] "SD" "SI" "MI" "SI"
[4,] "MI" "SI" "SI" "MI"
Run Code Online (Sandbox Code Playgroud)
我不明白这是怎么回事。