在将'Lukasieicz‘这个名字转换为soundex (字母、数字、数字)时,我想到了L2222。
然而,我的演讲幻灯片告诉我,实际的答案应该是L2220。
请解释为什么我的答案是不正确的,或者讲座的答案只是一个打字错误之类的。
我的步骤:
Lukasieicz
remove and keep L
ukasieicz
Remove contiguous duplicate characters
ukasieicz
remove A,E,H,I,O,U,W,Y
KSCZ
convert up to first four remaining letters to soundex (as described in lecture directions)
2222
append beginning letter
L2222发布于 2015-10-17 04:08:37
如果这是作为defined by the National Archives的American Soundex,那么你们都错了。American Soundex包含一个字母和三个数字,您不能有L2222或L2220。我是L222。
但是假设他们出于某种原因添加了另一个数字。
基本的替换给出了L2222。但您应该折叠具有相同数字的相邻字母(下面的步骤3),然后在必要时填充零(步骤4)。
Lukasieicz # the original word
L_2_2___22 # replace with numbers, leave the gaps in
L_2_2___2 # apply step 3 and squeeze adjacent numbers
L2220 # apply step 4 and pad to four numbers我们可以检查如何常规(即,三个数字) soundex实现使用更短的Lukacz,它变成了L_2_22。根据规则3和4,它应该是L220。
National Archives建议使用可生成L220的online Soundex calculator。So does PostgreSQL和Text::Soundex在其原始风格和NARA实现中。
$ perl -wle 'use Text::Soundex; print soundex("Lukacz"); print soundex_nara("Lukacz")'
L220
L220MySQL,不出所料,就是is doing its own thing and returns L200。
这个函数实现了原始的Soundex算法,而不是更流行的增强版本(也由D.Knuth描述)。不同的是,原始版本首先丢弃元音,然后复制,而增强版本首先丢弃重复,然后丢弃元音。
总而言之,您忘记了挤压步骤。
https://stackoverflow.com/questions/33178663
复制相似问题