【发布时间】:2014-06-10 17:56:53
【问题描述】:
我遇到了一个非常顽固的问题...我似乎无法从 Corpora 中删除已从 *.txt 文件加载到 R 中的 <+f0b7> 和 <+f0a0> 字符串:
更新这是示例.txt文件的链接:https://db.tt/qTRKpJYK
Corpus(DirSource("./SomeDirectory/txt/"), readerControl = list(reader = readPlain))
title
professional staff - contract - permanent position
software c microfocus cobol unix btrieve ibm vm-cms vsam cics jcl
accomplishments
<+f0b7>
<+f0a0>
responsible maintaining billing system interfaced cellular switching system <+f0b7>
<+f0a0>
developed unix interface ibm mainframe ericsson motorola att cellular switches
我已尝试将其添加到:
badWords <- unique(c(stopwords("en"),
stopwords("SMART")[stopwords("SMART") != "c"],
as.character(1970:2050),
"<U+F0B7>", "<+f0b7>",
"<U+F0A0>", "<+f0a0>",
"january", "jan",
"february", "feb",
"march", "mar",
"april", "apr",
"may", "may",
"june", "jun",
"july", "jul",
"august", "aug",
"september", "sep",
"october", "oct",
"november", "nov",
"december", "dec"))
并使用:
tm_map(candidates.Corpus, removeWords, badWords)
但这无论如何都行不通。我还尝试使用 gsub("<+f0a0>", "", tmp, perl = FALSE) 之类的东西对其进行正则表达式,这适用于 R 中的字符串,但不知何故,当我读取 .txt 文件时,这些字符仍然出现。
这些角色有什么独特之处吗?我该如何摆脱它们?
【问题讨论】:
-
那么您是说字符串
"<U+F0B7>"出现在您的文本中,还是说Unicode 字符<U+F0B7>出现在您的文本中? R 是否将此值打印到屏幕上? -
当我
inspect()Corpus 元素时,R 实际上将这个值打印到我的屏幕上。 -
请提供数据以重现此错误。
-
抱歉耽搁了,这里是一个示例 .txt 文件的链接:db.tt/qTRKpJYK