NYSIIS: Difference between revisions

33 bytes added ,  11 years ago
m
Allow for small suffix/honours list (too large otherwise)
m (Modified task description for clarity)
m (Allow for small suffix/honours list (too large otherwise))
Line 5:
The task here is to implement the original NYSIIS algorithm, shown in Wikipedia, rather than any other subsequent modification. Also, before the algorithm is applied the input string should be converted to upper case with all white space removed.
 
An optional step is to handle multiple names, including double-barrelled names or double surnamesurnames (e.g. 'Hoyle-Johnson' or 'Vaughan Williams') and unnecessary suffixes/honours that are not required for indexing purposes (e.g. 'Jnr', 'Sr', 'III', 'CBE'etc) - a small selection will suffice. The original implementation is also restricted to six characters, but this is not a requirement.
 
;See also
Line 78:
// translate first characters of name:
// => MAC->MCC, KN->N, K->C, PH/PF->FF, SCH->SSS
For rule="^MAC->MCC", "^KN->N", "^K->C", "^(PH|PF)->FF", "^SCH->SSS" {
Set rem.Pattern=$Piece(rule, "->")
If rem.Locate() Set rem.Text=rem.ReplaceFirst($Piece(rule, "->", 2)) Quit