Class DoubleMetaphone
Encodes a string into a double metaphone value. This Implementation is based on the algorithm by Lawrence
Philips
.
This class is conditionally thread-safe. The instance field Lucene.Net.Analysis.Phonetic.Language.DoubleMetaphone.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.
See Original Article
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Analysis.Phonetic.Language
Assembly: Lucene.Net.Analysis.Phonetic.dll
Syntax
public class DoubleMetaphone : IStringEncoder
Constructors
| Improve this Doc View SourceDoubleMetaphone()
Creates an instance of this DoubleMetaphone encoder
Declaration
public DoubleMetaphone()
Properties
| Improve this Doc View SourceMaxCodeLen
Gets or Sets the maxCodeLen.
Declaration
public virtual int MaxCodeLen { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceCharAt(String, Int32)
Gets the character at index index
if available, otherwise
it returns System.Char.MinValue so that there is some sort
of a default.
Declaration
protected virtual char CharAt(string value, int index)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | |
System.Int32 | index |
Returns
Type | Description |
---|---|
System.Char |
Contains(String, Int32, Int32, String[])
Determines whether value
contains any of the criteria starting at index start
and
matching up to length length
.
Declaration
protected static bool Contains(string value, int start, int length, params string[] criteria)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | |
System.Int32 | start | |
System.Int32 | length | |
System.String[] | criteria |
Returns
Type | Description |
---|---|
System.Boolean |
Encode(String)
Encode the value using DoubleMetaphone.
Declaration
public virtual string Encode(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | String to encode. |
Returns
Type | Description |
---|---|
System.String | An encoded string. |
GetDoubleMetaphone(String)
Encode a value with Double Metaphone.
Declaration
public virtual string GetDoubleMetaphone(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | String to encode. |
Returns
Type | Description |
---|---|
System.String | An encoded string. |
GetDoubleMetaphone(String, Boolean)
Encode a value with Double Metaphone, optionally using the alternate encoding.
Declaration
public virtual string GetDoubleMetaphone(string value, bool alternate)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | String to encode. |
System.Boolean | alternate | Use alternate encode. |
Returns
Type | Description |
---|---|
System.String | An encoded string. |
IsDoubleMetaphoneEqual(String, String)
Check if the Double Metaphone values of two System.String values are equal.
Declaration
public virtual bool IsDoubleMetaphoneEqual(string value1, string value2)
Parameters
Type | Name | Description |
---|---|---|
System.String | value1 | The left-hand side of the encoded System.String.Equals(System.Object). |
System.String | value2 | The right-hand side of the encoded System.String.Equals(System.Object). |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsDoubleMetaphoneEqual(String, String, Boolean)
Check if the Double Metaphone values of two System.String values are equal, optionally using the alternate value.
Declaration
public virtual bool IsDoubleMetaphoneEqual(string value1, string value2, bool alternate)
Parameters
Type | Name | Description |
---|---|---|
System.String | value1 | The left-hand side of the encoded System.String.Equals(System.Object). |
System.String | value2 | The right-hand side of the encoded System.String.Equals(System.Object). |
System.Boolean | alternate | Use the alternate value if |
Returns
Type | Description |
---|---|
System.Boolean |
|