Class Nysiis
Encodes a string into a NYSIIS value. NYSIIS is an encoding used to relate similar names, but can also be used as a general purpose scheme to find word with similar phonemes.
Implements
Inherited Members
Namespace: Lucene.Net.Analysis.Phonetic.Language
Assembly: Lucene.Net.Analysis.Phonetic.dll
Syntax
public class Nysiis : IStringEncoder
  Remarks
NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm.
Algorithm description:- Transcode first characters of name
- MAC -> MCC
 - KN -> NN
 - K -> C
 - PH -> FF
 - PF -> FF
 - SCH -> SSS
 
 - Transcode last characters of name
- EE, IE -> Y
 - DT,RT,RD,NT,ND -> D
 
 - First character of key = first character of name
 - Transcode remaining characters by following these rules, incrementing by one character each time
- EV -> AF else A,E,I,O,U -> A
 - Q -> G
 - Z -> S
 - M -> N
 - KN -> N else K -> C
 - SCH -> SSS
 - PH -> FF
 - H -> If previous or next is nonvowel, previous
 - W -> If previous is vowel, previous
 - Add current to key if current != last key character
 
 - If last character is S, remove it
 - If last characters are AY, replace with Y
 - If last character is A, remove it
 - Collapse all strings of repeated characters
 - Add original first character of name as first character of key
 
Constructors
Nysiis()
Creates an instance of the Nysiis encoder with strict mode (original form), i.e. encoded strings have a maximum length of 6.
Declaration
public Nysiis()
  Remarks
NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm.
Algorithm description:- Transcode first characters of name
- MAC -> MCC
 - KN -> NN
 - K -> C
 - PH -> FF
 - PF -> FF
 - SCH -> SSS
 
 - Transcode last characters of name
- EE, IE -> Y
 - DT,RT,RD,NT,ND -> D
 
 - First character of key = first character of name
 - Transcode remaining characters by following these rules, incrementing by one character each time
- EV -> AF else A,E,I,O,U -> A
 - Q -> G
 - Z -> S
 - M -> N
 - KN -> N else K -> C
 - SCH -> SSS
 - PH -> FF
 - H -> If previous or next is nonvowel, previous
 - W -> If previous is vowel, previous
 - Add current to key if current != last key character
 
 - If last character is S, remove it
 - If last characters are AY, replace with Y
 - If last character is A, remove it
 - Collapse all strings of repeated characters
 - Add original first character of name as first character of key
 
See Also
Nysiis(bool)
Create an instance of the Nysiis encoder with the specified strict mode:
true:encoded strings have a maximum length of 6false:encoded strings may have arbitrary length
Declaration
public Nysiis(bool strict)
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | strict | The strict mode.  | 
      
Remarks
NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm.
Algorithm description:- Transcode first characters of name
- MAC -> MCC
 - KN -> NN
 - K -> C
 - PH -> FF
 - PF -> FF
 - SCH -> SSS
 
 - Transcode last characters of name
- EE, IE -> Y
 - DT,RT,RD,NT,ND -> D
 
 - First character of key = first character of name
 - Transcode remaining characters by following these rules, incrementing by one character each time
- EV -> AF else A,E,I,O,U -> A
 - Q -> G
 - Z -> S
 - M -> N
 - KN -> N else K -> C
 - SCH -> SSS
 - PH -> FF
 - H -> If previous or next is nonvowel, previous
 - W -> If previous is vowel, previous
 - Add current to key if current != last key character
 
 - If last character is S, remove it
 - If last characters are AY, replace with Y
 - If last character is A, remove it
 - Collapse all strings of repeated characters
 - Add original first character of name as first character of key
 
See Also
Properties
IsStrict
Indicates the strict mode for this Nysiis encoder.
true if the encoder is configured for strict mode, false otherwise.
Declaration
public virtual bool IsStrict { get; }
  Property Value
| Type | Description | 
|---|---|
| bool | 
Remarks
NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm.
Algorithm description:- Transcode first characters of name
- MAC -> MCC
 - KN -> NN
 - K -> C
 - PH -> FF
 - PF -> FF
 - SCH -> SSS
 
 - Transcode last characters of name
- EE, IE -> Y
 - DT,RT,RD,NT,ND -> D
 
 - First character of key = first character of name
 - Transcode remaining characters by following these rules, incrementing by one character each time
- EV -> AF else A,E,I,O,U -> A
 - Q -> G
 - Z -> S
 - M -> N
 - KN -> N else K -> C
 - SCH -> SSS
 - PH -> FF
 - H -> If previous or next is nonvowel, previous
 - W -> If previous is vowel, previous
 - Add current to key if current != last key character
 
 - If last character is S, remove it
 - If last characters are AY, replace with Y
 - If last character is A, remove it
 - Collapse all strings of repeated characters
 - Add original first character of name as first character of key
 
See Also
Methods
Encode(string)
Encodes a string using the NYSIIS algorithm.
Declaration
public virtual string Encode(string str)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | str | A string object to encode.  | 
      
Returns
| Type | Description | 
|---|---|
| string | A Nysiis code corresponding to the string supplied.  | 
      
Remarks
NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm.
Algorithm description:- Transcode first characters of name
- MAC -> MCC
 - KN -> NN
 - K -> C
 - PH -> FF
 - PF -> FF
 - SCH -> SSS
 
 - Transcode last characters of name
- EE, IE -> Y
 - DT,RT,RD,NT,ND -> D
 
 - First character of key = first character of name
 - Transcode remaining characters by following these rules, incrementing by one character each time
- EV -> AF else A,E,I,O,U -> A
 - Q -> G
 - Z -> S
 - M -> N
 - KN -> N else K -> C
 - SCH -> SSS
 - PH -> FF
 - H -> If previous or next is nonvowel, previous
 - W -> If previous is vowel, previous
 - Add current to key if current != last key character
 
 - If last character is S, remove it
 - If last characters are AY, replace with Y
 - If last character is A, remove it
 - Collapse all strings of repeated characters
 - Add original first character of name as first character of key
 
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | If a character is not mapped.  | 
      
See Also
GetNysiis(string)
Retrieves the NYSIIS code for a given string.
Declaration
public virtual string GetNysiis(string str)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | str | String to encode using the NYSIIS algorithm.  | 
      
Returns
| Type | Description | 
|---|---|
| string | A NYSIIS code for the string supplied.  | 
      
Remarks
NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm.
Algorithm description:- Transcode first characters of name
- MAC -> MCC
 - KN -> NN
 - K -> C
 - PH -> FF
 - PF -> FF
 - SCH -> SSS
 
 - Transcode last characters of name
- EE, IE -> Y
 - DT,RT,RD,NT,ND -> D
 
 - First character of key = first character of name
 - Transcode remaining characters by following these rules, incrementing by one character each time
- EV -> AF else A,E,I,O,U -> A
 - Q -> G
 - Z -> S
 - M -> N
 - KN -> N else K -> C
 - SCH -> SSS
 - PH -> FF
 - H -> If previous or next is nonvowel, previous
 - W -> If previous is vowel, previous
 - Add current to key if current != last key character
 
 - If last character is S, remove it
 - If last characters are AY, replace with Y
 - If last character is A, remove it
 - Collapse all strings of repeated characters
 - Add original first character of name as first character of key