Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class Metaphone

    Encodes a string into a Metaphone value.

    Initial Java implementation by William B. Brogden. December, 1997. Permission given by wbrogden for code to be used anywhere.

    Hanging on the Metaphone by Lawrence Philips in Computer Language of Dec. 1990, p 39.

    Note, that this does not match the algorithm that ships with PHP, or the algorithm found in the Perl implementations:

    • Text:Metaphone-1.96 (broken link 4/30/2013)
    • Text:Metaphone-1.96 (link checked 4/30/2013)

    They have had undocumented changes from the originally published algorithm. For more information, see CODEC-57.

    This class is conditionally thread-safe. The instance field maxCodeLen is mutable MaxCodeLen but is not volatile, and accesses are not synchronized. If an instance of the class is shared between threads, the caller needs to ensure that suitable synchronization is used to ensure safe publication of the value between threads, and must not set MaxCodeLen after initial setup.
    Inheritance
    object
    Metaphone
    Implements
    IStringEncoder
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Analysis.Phonetic.Language
    Assembly: Lucene.Net.Analysis.Phonetic.dll
    Syntax
    public class Metaphone : IStringEncoder

    Constructors

    Metaphone()

    Creates an instance of the Metaphone encoder

    Declaration
    public Metaphone()

    Properties

    MaxCodeLen

    Gets or Sets maxCodeLen.

    Declaration
    public virtual int MaxCodeLen { get; set; }
    Property Value
    Type Description
    int

    Methods

    Encode(string)

    Encodes a string using the Metaphone algorithm.

    Declaration
    public virtual string Encode(string str)
    Parameters
    Type Name Description
    string str

    String to encode.

    Returns
    Type Description
    string

    The metaphone code corresponding to the string supplied.

    GetMetaphone(string)

    Find the metaphone value of a string. This is similar to the soundex algorithm, but better at finding similar sounding words. All input is converted to upper case. Limitations: Input format is expected to be a single ASCII word with only characters in the A - Z range, no punctuation or numbers.

    Declaration
    public virtual string GetMetaphone(string txt)
    Parameters
    Type Name Description
    string txt

    String to find the metaphone code for.

    Returns
    Type Description
    string

    A metaphone code corresponding to the string supplied.

    IsMetaphoneEqual(string, string)

    Tests is the metaphones of two strings are identical.

    Declaration
    public virtual bool IsMetaphoneEqual(string str1, string str2)
    Parameters
    Type Name Description
    string str1

    First of two strings to compare.

    string str2

    Second of two strings to compare.

    Returns
    Type Description
    bool

    true if the metaphones of these strings are identical, false otherwise.

    Implements

    IStringEncoder
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.