我一直在使用R的文本挖掘包,它真的是一个很棒的工具。我没有找到检索支持或者可能有我缺少的功能。 如何使用R的文本挖掘包实现简单的VSM模型?
答案 0 :(得分:1)
# Sample R commands in support of my previous answer
require(fortunes)
require(tm)
sentences <- NULL
for (i in 1:10) sentences <- c(sentences,fortune(i)$quote)
d <- data.frame(textCol =sentences )
ds <- DataframeSource(d)
dsc<-Corpus(ds)
dtm<- DocumentTermMatrix(dsc, control = list(weighting = weightTf, stopwords = TRUE))
dictC <- Dictionary(dtm)
# The query below is created from words in fortune(1) and fortune(2)
newQry <- data.frame(textCol = "lets stand up and be counted seems to work undocumented")
newQryC <- Corpus(DataframeSource(newQry))
dtmNewQry <- DocumentTermMatrix(newQryC, control = list(weighting=weightTf,stopwords=TRUE,dictionary=dict1))
dictQry <- Dictionary(dtmNewQry)
# Below does a naive similarity (number of features in common)
apply(dtm,1,function(x,y=dictQry){length(intersect(names(x)[x!= 0],y))})
答案 1 :(得分:0)
假设VSM =向量空间模型,您可以通过以下方式进行简单的检索系统:
非R方法是在PostgreSQL中的表的文本列(行是文档)上使用GINI索引。使用ts_vector查询方法,您可以拥有一个非常快速的检索系统。