【发布时间】:2020-07-04 22:12:41
【问题描述】:
我正在尝试从 rcorpora 包中复制“句子”对象的格式,但我对它是如何制作的有点困惑。
sentences 对象是一个包含 720 个句子的向量,但我对确切的结构和它是如何制作的感到困惑。
基于
is.list(sentences) returning FALSE
is.vector(sentences) returning TRUE
is.character(sentences) returning TRUE
我总结的对象句子是一个向量而不是一个列表。
每个句子都在不同的行,如图所示:
> head(sentences)
[1] "The birch canoe slid on the smooth planks."
[2] "Glue the sheet to the dark blue background."
[3] "It's easy to tell the depth of a well."
[4] "These days a chicken leg is a rare dish."
[5] "Rice is often served in round bowls."
[6] "The juice of lemons makes fine punch."
但是当我尝试像这样构建自己的句子版本时
sentence2 <- c("This is the first sentence.\n", "This is the second sentence"
或
sentence3 <- c("This is the first sentence. \n This is the second sentence")
我没有得到相同的结果。
如何创建句子对象/向量以使每个句子位于不同的行并具有不同的编号?
【问题讨论】: