【发布时间】:2014-03-17 13:51:05
【问题描述】:
我有大量包含正常句子的文本文件(超过 50,000 个)。其中一些句子的单词已经合并在一起,因为一些尾线已经放在一起。如何在 R 中取消合并其中的一些单词?
我能得到的唯一建议是 here 和 kind of attempted something from here 但这两个建议都需要我无法使用的大矩阵,因为我要么内存不足,要么 RStudio 崩溃:(有人可以帮忙吗?这是一个例子我正在使用的一个文本文件(还有 50,000 多个来源):
Mad cow disease, BSE, or bovine spongiform encephalopathy, has cost the country dear.
More than 170,000 cattle in England, Scotland and Wales have contracted BSE since 1988.
More than a million unwanted calves have been slaughtered, and more than two and a quarter million older cattle killed, their remains dumped in case they might be harbouring the infection.
In May, one of the biggest cattle markets, at Banbury in Oxfordshire, closed down. Avictim at least in part, of this bizarre crisis.
The total cost of BSE to the taxpayer is set to top £4 billion.
编辑:例如: “一直靠补贴缓冲,生活在一个不真实的世界里。很多农民根本没想过农场门外发生了什么,因为总有人愿意买他们生产的东西。”
请参阅“关于什么”部分。好吧,大约每 100 篇左右的文章中就有 1 篇发生这种情况。不是这篇实际的文章,我只是将以上内容作为示例。这些单词以某种方式连接在一起(我想当我在一些文章中阅读时,其中一些文章遗漏了空格,或者我的记事本阅读器将一行的末尾与另一行连接在一起)。
编辑 2:这是我在使用 here 用读入列表替换创建的列表时遇到的错误:
Error: assertion 'tree->num_tags == num_tags' failed in executing regexp: file 'tre-compile.c', line 627
【问题讨论】:
-
每个句子都独占一行吗?当您说单词“合并”时,您是什么意思?
-
@Justin 我现在用一个例子来编辑。
-
no 每个句子都不在自己的行上。这取决于文章(通常是段落)。
-
是 R 真的是解决这个问题的“正确”地方,你提到“当我在一些文章中阅读时”这表明你已经从其他格式转换了这些 - 我会尝试解决这个问题在那里。
-
@SamMason 嗨 Sam 我这样做是因为我打算使用 R 进行练习,因为我没有太多经验。我以文本文件的形式阅读了这些文章。我会手动更改它们,但是太多了,而且我显然无法找到已连接的每个单词。如果它不能在 R 中完成,那么好吧。
标签: r