Click or drag to resize

WordLevenshtein Class

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
This class implements WordLevenshtein algorithm. We can instantiate an object with a query string, then by invoking the GetDistance() method we can get the WordLevenshtein distances between this query string and any number of test strings. WordLevenshtein distance is similar to Levenshtein distance with customized edit distance of a missing word or extra word in the query string relative to a test string. For further explanation please see the example below.
Inheritance Hierarchy
SystemObject
  Telogis.GeoBase.IndexesWordLevenshtein

Namespace:  Telogis.GeoBase.Indexes
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public class WordLevenshtein : IDisposable

The WordLevenshtein type exposes the following members.

Constructors
  NameDescription
Public methodWordLevenshtein
Creates a WordLevenshtein object
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by the WordLevenshtein
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetDistance
Calculate the distance between this WordLevenshtein object and a test string
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
C#
// We instantiate a WordLevenshtein object with the query string "Brown Tail", with
// a maxEditDistance of 5, with a missingWordCost of 1 and with an extraWordCost of 4.
// Then we calculate against four test strings. Note the matching is case insensitive.
// Also note this class is IDisposable.
using (var lev = new WordLevenshtein("Brown Tail", 5, 1, 4)) {
    // The query string has an extra word "Brown" than the test string, so the result is 4.
    Console.WriteLine(lev.GetDistance("Tail"));

    // The query string lacks a word "kangaroo" from the test string, so the result is 1.
    Console.WriteLine(lev.GetDistance("brown tail kangaroo"));

    // This is the same as the original Levenshtein algorithm with a result of 2.
    Console.WriteLine(lev.GetDistance("BROWNTRAIL"));

    // This calculation reaches the maximum edit distance, so the result is 5. 
    Console.WriteLine(lev.GetDistance("Completely different"));
}
See Also