问题描述
限时送ChatGPT账号..我使用的是 {tm} 包,然后使用
I was using {tm} package and then generated a corpus using
corpus = Corpus(VectorSource(sample.words))
然后我想检查语料库中的内容,但它打印了这个而不是它的文本:
then I want to check the content in corpus ,but it print this instead of its texts:
> corpus
<<VCorpus>>
Metadata: corpus specific: 0, document level (indexed): 0
Content: documents: 3933
现在我已经找到了一些查看语料库
的方法,然后我开始想知道当一个对象被输入时R到底打印了什么?
Now I have found some methods to look into corpus
,then I started wondering what exactly R print when an object was typed in ?
> class(corpus)
[1] "VCorpus" "Corpus"
> typeof(corpus)
[1] "list"
为什么它不喜欢其他普通列表,打印其列和行?这与 class 属性有关吗?
Why it didn`t like other ordinary lists ,printing its columns and rows?Does this has something to do whit the class attribute?
我是 R 新手,不熟悉一些基本概念,感谢您的耐心等待!
I`m new in R and not familiar with some basic concepts, thanks for your patience!
推荐答案
tm
包的介绍文档说你可以使用,比如 writeLines(as.character(mycorpus[[4]]))
获取文档 4 的文本表示.
The introduction document to the tm
package says that you can use , say, writeLines(as.character(mycorpus[[4]]))
to get a textual representation of document 4.
您也可以使用content(myCorpus[[23]])
.
要阅读介绍文档,请在 R 提示符下输入 browseVignettes()
并在将打开的浏览器窗口中搜索它.
To read the intro document, enter browseVignettes()
on your R prompt and the search for it on the browser window that will have opened.
这篇关于如何打印存储在 R 中 tm 语料库中的单个文档的文本表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论