【发布时间】:2012-12-09 15:24:15
【问题描述】:
我想通过执行类似这样的简单操作来修改由语料库索引的现有文档
myCorpus[[10]] = "hey I am the new content of this document"
这有效吗?
【问题讨论】:
-
我猜你想追加你的 textDocument 语料库列表?
标签: r text text-mining
我想通过执行类似这样的简单操作来修改由语料库索引的现有文档
myCorpus[[10]] = "hey I am the new content of this document"
这有效吗?
【问题讨论】:
标签: r text text-mining
不清楚你想用你的语料库做什么。追加您的语料库或修改第 10 个元素?
我想说,作为语法它是正确的,但作为语义是错误的。
从概念上讲,语料库是元数据和 TextDocument 的列表。所以, 您可以使用“[[”或“$”作为任何 R 列表访问此列表。
所以如果你这样做(最好使用
myCorpus[[10]] <- "hey I am the new content of this document"
这将创建或更改第 10 个元素,但使用的是 character 类元素而不是 TextDocument。所以你不能在类上应用使用方法
所以要更新10个文本文档的内容:
Content(myCorpus[[10]]) <- "hey I am the new content of this document"
要创建新元素,请使用:
tmUpdate(ovid, DirSource(txt))
检查源中是否存在文档集合中尚不存在的新文件。 被解析并添加到现有的文档集合中。
【讨论】:
c 使用,c(corpus1, corpus2) 与 c(1,1) 类似,请参阅 ?c 了解更多信息。