使用 R 的 tm 包,VectorSource 生成一个列表而不是语料库

With R's tm package, VectorSource produces a list instead of corpus

提问人:mnr 提问时间:2/24/2023 更新时间:2/24/2023 访问量:28

问:

以下代码...

library(tm)

vectorOfText <- c("twas brillig and the slithey toves", 
                  "did gyre and gimble in the wabes")
names(vectorOfText) <- c("firstLine", "secondLine")

aCorpus <- VCorpus(VectorSource(vectorOfText))

使用 List of 2 的类生成 - 它应该生成一个 VCorpus。至少,RStudio 环境窗口中显示 List of 2aCorpus

但是,在控制台中执行会生成正确的类。例如class(aCorpus)

> class(aCorpus)
[1] "VCorpus" "Corpus"

这是 tm 和 RStudio 之间的已知问题吗?

R TM 语料库

评论

1赞 MrFlick 2/24/2023
两者都是对的。这是一个长度为 2 的列表,带有一个 VCorpus 类。 RStudio 刚刚决定在查看器中显示类似列表的趋势更重要。您是否真的遇到了行为不同的问题?否则,请始终信任 class(),因为它通常描述对象的行为。这只是看待同一对象的两种不同方式。

答: 暂无答案