[Jprogramming] spelling correction
Pascal Jasmin
godspiral2000 at yahoo.ca
Tue Nov 12 18:00:49 UTC 2013
Here is one approach to doing spelling corrections/coercions
corrections =: 0 : 0
USA;United States;U.S.A.;US;
UK;U.K.;
)
c=: < ;. _2 each < ;. _2 corrections
spellcorrect =: c & (( (<'Unknown Country'),~ {.("1)(&>)@:[) {~ 1: i.~ <@:] +/"1@:e.~ >@:[)
spellcorrect 'UK'
┌──┐
│UK│
└──┘
spellcorrect 'U.K.'
┌──┐
│UK│
└──┘
spellcorrect 'U.Kong'
┌───────────────┐
│Unknown Country│
└───────────────┘
spellcorrect 'U.S.A.'
┌───┐
│USA│
└───┘
Would you change/improve the spellcorrect verb?
More information about the Programming
mailing list