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

    Constructors

    | Improve this Doc View Source

    Metaphone()

    Creates an instance of the Metaphone encoder

    Declaration
    public Metaphone()

    Properties

    | Improve this Doc View Source

    MaxCodeLen

    Gets or Sets Lucene.Net.Analysis.Phonetic.Language.Metaphone.maxCodeLen.

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

    Methods

    | Improve this Doc View Source

    Encode(String)

    Encodes a string using the Metaphone algorithm.

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

    String to encode.

    Returns
    Type Description
    System.String

    The metaphone code corresponding to the string supplied.

    | Improve this Doc View Source

    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
    System.String txt

    String to find the metaphone code for.

    Returns
    Type Description
    System.String

    A metaphone code corresponding to the string supplied.

    | Improve this Doc View Source

    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
    System.String str1

    First of two strings to compare.

    System.String str2

    Second of two strings to compare.

    Returns
    Type Description
    System.Boolean

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

    Implements

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