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.
Inheritance
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
This class is immutable and thread-safe.
See: NYSIIS on Wikipedia
See: NYSIIS on dropby.com
since 1.7
Constructors
| Improve this Doc View SourceNysiis()
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()
Nysiis(Boolean)
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 |
---|---|---|
System.Boolean | strict | The strict mode. |
Properties
| Improve this Doc View SourceIsStrict
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 |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceEncode(String)
Encodes a string using the NYSIIS algorithm.
Declaration
public virtual string Encode(string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | A string object to encode. |
Returns
Type | Description |
---|---|
System.String | A Nysiis code corresponding to the string supplied. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If a character is not mapped. |
GetNysiis(String)
Retrieves the NYSIIS code for a given string.
Declaration
public virtual string GetNysiis(string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | String to encode using the NYSIIS algorithm. |
Returns
Type | Description |
---|---|
System.String | A NYSIIS code for the string supplied. |