有人知道如何生成可能的拼写错误吗?
例子:失业-就业-在线就业网--等等。
发布于 2011-04-13 12:20:11
如果您只想生成一个可能的拼写错误列表,您可以尝试使用this one之类的工具。如果按照您的标准,这两个文本“足够接近”,请将它们的文本替换为您想要的文本。
这是一个计算“失业”和各种看似合理的错误之间的广义编辑距离的例子。
data misspell;
input misspell $16.;
length misspell string $16.;
retain string "unemployment";
GED=compged(misspell, string,'iL');
datalines;
nemployment
uemployment
unmployment
uneployment
unemloyment
unempoyment
unemplyment
unemploment
unemployent
unemploymnt
unemploymet
unemploymen
unemploymenyt
unemploymenty
unemploymenht
unemploymenth
unemploymengt
unemploymentg
unemploymenft
unemploymentf
blahblah
;
proc print data=misspell label;
label GED='Generalized Edit Distance';
var misspell string GED;
run;发布于 2011-04-23 02:08:04
本质上,您正在尝试根据一些经验规则开发文本字符串列表,例如单词中缺少一个字母,一个字母被错误地放在错误的位置,一个字母被错误地键入,等等。问题是,在您可以用SAS或任何其他语言(这就是Chris所指的)编写代码之前,必须显式地定义这些规则。如果您的需求简化为一个字母错误的场景,那么这可能是可控的;否则,评论者是正确的,您可以很容易地创建大量错误拼写的列表(毕竟,所有组合,除了“失业”构成了该单词的拼写错误)。
话虽如此,在SAS中有许多方法可以完成此文本操作(rx函数、其他文本字符串函数的某种组合、宏);但是,可能还有更好的方法来完成此操作。我建议使用外部Perl进程来生成可读入SAS的文本文件,但其他程序员可能有更好的选择。
发布于 2011-04-13 16:17:06
如果你正在寻找一个通用的拼写检查器,SAS确实有proc spell。
它需要一些调整才能使其适合您的情况;它非常陈旧和笨重。它在这种情况下不能很好地工作,但是如果你尝试使用其他字典,你可能会有更好的结果?谷歌搜索还会显示其他的例子。
filename name temp lrecl=256;
options caps;
data _null_;
file name;
informat name $256.;
input name &;
put name;
cards;
uemployment
onemploymnet
;
proc spell in=name
dictionary=SASHELP.BASE.NAMES
suggest;
run;
options nocaps;https://stackoverflow.com/questions/5642001
复制相似问题