Show / Hide Table of Contents

    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
    System.Object
    Nysiis
    Implements
    IStringEncoder
    Namespace: Lucene.Net.Analysis.Phonetic.Language
    Assembly: Lucene.Net.Analysis.Phonetic.dll
    Syntax
    public class Nysiis : object, IStringEncoder
    Remarks

    NYSIIS features an accuracy increase of 2.7% over the traditional Soundex algorithm.

    Algorithm description:

    1. Transcode first characters of name
      1. MAC -> MCC
      2. KN -> NN
      3. K -> C
      4. PH -> FF
      5. PF -> FF
      6. SCH -> SSS
    2. Transcode last characters of name
      1. EE, IE -> Y
      2. DT,RT,RD,NT,ND -> D
    3. First character of key = first character of name
    4. Transcode remaining characters by following these rules, incrementing by one character each time
      1. EV -> AF else A,E,I,O,U -> A
      2. Q -> G
      3. Z -> S
      4. M -> N
      5. KN -> N else K -> C
      6. SCH -> SSS
      7. PH -> FF
      8. H -> If previous or next is nonvowel, previous
      9. W -> If previous is vowel, previous
      10. Add current to key if current != last key character
    5. If last character is S, remove it
    6. If last characters are AY, replace with Y
    7. If last character is A, remove it
    8. Collapse all strings of repeated characters
    9. 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 Source

    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()
    | Improve this Doc View Source

    Nysiis(Boolean)

    Create an instance of the Nysiis encoder with the specified strict mode:

    • true:encoded strings have a maximum length of 6
    • false: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 Source

    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
    System.Boolean

    Methods

    | Improve this Doc View Source

    Encode(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.

    | Improve this Doc View Source

    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.

    Implements

    IStringEncoder

    See Also

    Soundex
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)