【问题标题】:sas generate all possible miss spellingsas 生成所有可能的拼写错误
【发布时间】:2011-08-04 06:16:53
【问题描述】:

有谁知道如何生成可能的拼写错误?

示例:失业 - 就业 - oneemploymnet -- 等等

【问题讨论】:

  • 拼写错误的定义是什么? “就业”是“失业”的变体吗?没有定义,集合可以是无限的。
  • 老兄。说真的,你应该不时接受偶尔的回答。 0% 太可怕了。
  • 我正在寻找可以帮助我生成有助于抑制拼错雇主名称的客户的代码:
  • 您应该回到您提出的问题并接受答案(我相信这是您单击答案旁边的复选标记)。

标签: text sas mining misspelling


【解决方案1】:

如果您只想生成可能的拼写错误列表,您可以尝试使用this one 之类的工具。否则,在 SAS 中,您可能可以使用 COMPGED 之类的函数来计算某人输入的字符串与您希望他们输入的字符串之间的相似度。如果按照您的标准,两者“足够接近”,请将其文本替换为您想要的。

这是一个计算“失业”与各种可能的拼写错误之间的广义编辑距离的示例。

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;

【讨论】:

  • 谢谢约翰,我实际上是在寻找所有可能的值作为 sas 输出。我应该更清楚.. 所以我正在寻找一个可以给我输出的 sas 代码: nemployment uemployment unmployment uneployment unemloyment unemployment unemployment unemployment unemployment unemploymnt unemploymet unemploymen unemploymenyt unlocky unemploymenht失业 unemploymengt失业g unemploymenft失业f .. p
  • 我不认为你真的想要生成所有可能的拼写错误然后匹配该列表提供的内容,而是使用此处建议的 COMPGED 来匹配预期列表中提供的内容如果拼写距离适当低,则说它是匹配的。
【解决方案2】:

本质上,您是在尝试根据一些经验法则开发一个文本字符串列表,例如单词中缺少一个字母、一个字母放错位置、一个字母输入错误等。问题是在编写代码之前必须明确定义这些规则,使用 SAS 或任何其他语言(这就是 Chris 所指的)。如果您的要求减少到这种一个字母错误的情况,那么这可能是可以管理的;否则,评论者是正确的,您可以轻松创建大量错误拼写列表(毕竟,除了“unemployment”之外的所有组合都构成该词的拼写错误)。

话虽如此,SAS 中有很多方法可以完成这种文本操作(rx 函数、其他文本字符串函数的组合、宏);但是,可能有更好的方法来实现这一点。我建议使用外部 Perl 进程来生成可以读入 SAS 的文本文件,但其他程序员可能有更好的选择。

【讨论】:

    【解决方案3】:

    如果您正在寻找通用拼写检查器,SAS 确实有 proc spell

    需要进行一些调整才能使其适合您的情况;它很旧而且很笨重。在这种情况下它不能很好地工作,但是如果您尝试使用其他字典可能会有更好的结果? Google 搜索会显示其他示例。

    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;
    

    【讨论】:

    • 谢谢你,richie,但我应该更清楚.. 所以我正在寻找一个可以给我输出的 sas 代码:失业h unemploymengt失业g unemploymenft失业f ..
    猜你喜欢
    • 1970-01-01
    • 2018-12-07
    • 2021-10-20
    • 2021-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    • 2016-01-07
    相关资源
    最近更新 更多