【问题标题】:POS Tagging & Theme/Pattern Detection in RR中的POS标记和主题/模式检测
【发布时间】:2015-09-08 00:14:08
【问题描述】:

我是 R 新手,正在探索文本挖掘。使用以下步骤,我可以通过直到停止但是,我需要进行 POS 标记并获取文本/主题模式。我使用的数据是客户逐字记录。请帮助如何进一步进行。我查看的大多数文章都没有解释如何对语料库中的数据进行 POS 标记,而且我找不到有关模式检测的任何详细信息。任何帮助将不胜感激...!提前致谢,

CSVfile = read.csv("Testfortextcsv.csv",stringsAsFactors = FALSE)
TestSplit = as.data.frame(sent_detect_nlp(CSVfile$Comment))
colnames(TestSplit)[colnames(TestSplit)=="sent_detect_nlp(CSVfile$Comment)"]<- "Comment"
TestCorpus = Corpus(VectorSource(TestSplit$Comment))
TestCorpus = tm_map(TestCorpus, tolower)
TestCorpus = tm_map(TestCorpus, PlainTextDocument)
TestCorpus = tm_map(TestCorpus, removePunctuation)
TestCorpus = tm_map(TestCorpus, removeWords,c("Test",stopwords("SMART"),stopwords("english")))
TestCorpus = tm_map(TestCorpus, stripWhitespace)
TestCorpus = tm_map(TestCorpus, stemDocument)
dtm <- TermDocumentMatrix(TestCorpus)
m <- as.matrix(dtm)
v <- sort(rowSums(m),decreasing=TRUE)
d <- data.frame(word = names(v),freq=v)
head(d, 10)

我用它来获取 wordcloud、association 和 Barplot。


WordCloud
----------
set.seed(1234)
wordcloud(words = d$word, freq = d$freq, min.freq = 1,max.words=200,random.order=FALSE, rot.per=0.35, colors=brewer.pal(8,
"Dark2"))

Find Frequent Terms
-----------------
findFreqTerms(dtm, lowfreq = 15)

Find Association:
-----------------------
findAssocs(dtm, terms = "account", corlimit = 0.3)

Bar Plot for frequencies
--------------------------
barplot(d[1:10,]$freq, las = 2, names.arg = d[1:10,]$word,col ="lightblue", main ="Most frequent words",ylab = "Word frequencies")

【问题讨论】:

    标签: r themes text-analysis pos-tagger


    【解决方案1】:

    qdap 包允许您识别字符串中每个单词的词性。:

    library(qdap)
    s1<-c("Hello World")  
    pos(s1)
    

    您可能会找到其他资源 openNLPRTextToolsanother possibility

    【讨论】:

    • 谢谢@lawyeR。我认为它做了 POS 标记,但是我无法将它导出到 csv 文件。给我以下错误。 as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) 中的错误:无法将“pos”类强制转换为 data.frame
    • 请有人对文本主题模式/检测有所了解。提前致谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-27
    • 1970-01-01
    相关资源
    最近更新 更多