您的问题中没有代码,因此它并不适合该站点。也就是说,这里有一些可能有用的评论。如果您提供代码,您将获得更具体和有用的答案。
是的。将文本分成块是常见且可取的。确切的尺寸是一个品味问题。它通常在 R 中完成,我在制作语料库之前就完成了。您也可以像@holzben 建议的那样仅对名词进行子集化。这里有一些将语料库切割成块的代码:
corpus_chunk <- function(x, corpus, n) {
# convert corpus to list of character vectors
message("converting corpus to list of vectors...")
listofwords <- vector("list", length(corpus))
for(i in 1:length(corpus))
{
listofwords[[i]] <- corpus[[i]]
}
message("done")
# divide each vector into chunks of n words
# from http://stackoverflow.com/q/16232467/1036500
f <- function(x)
{
y <- unlist(strsplit(x, " "))
ly <- length(y)
split(y, gl(ly%/%n+1, n, ly))
}
message("splitting documents into chunks...")
listofnwords1 <- sapply(listofwords, f)
listofnwords2 <- unlist(listofnwords1, recursive = FALSE)
message("done")
# append IDs to list items so we can get bibliographic data for each chunk
lengths <- sapply(1:length(listofwords), function(i) length(listofnwords1[[i]]))
names(listofnwords2) <- unlist(lapply(1:length(lengths), function(i) rep(x$bibliodata$x[i], lengths[i])))
names(listofnwords2) <- paste0(names(listofnwords2), "_", unlist(lapply(lengths, function(x) seq(1:x))))
return(listofnwords2)
}
是的,您可能会从一些代码开始,然后再提出一个更具体的问题。这样您就可以充分利用本网站。
有关文本挖掘和主题建模的基本介绍,请参阅 Matthew Jockers为文学学生使用 R 的文本分析一书
如果您已经对 MALLET 有点熟悉,那么请尝试rmallet进行主题建模。网上有很多代码片段使用这个,这是我的一个。