SimilarityLevel

SimilarityLevel class

Represents an algorithm of the fuzzy search that specifies the similarity level. The similarity level algorithm calculates the maximum number of mistakes for a word as inversely proportional to the word length.

public class SimilarityLevel : FuzzyAlgorithm

Constructors

Name Description
SimilarityLevel(double) Initializes a new instance of the SimilarityLevel class.

Methods

Name Description
override GetMaxMistakeCount(int) Gets the maximum allowed number of mistakes for the specified term length.
override GetSimilarityLevel(int) Gets the similarity level value for the specified term length.

Remarks

Learn more

Examples

The example demonstrates a typical usage of the class.

string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
string query = "Einstein";

Index index = new Index(indexFolder); // Creating an index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder

SearchOptions options = new SearchOptions();
options.FuzzySearch.Enabled = true; // Enabling the fuzzy search
options.FuzzySearch.FuzzyAlgorithm = new SimilarityLevel(0.8); // Creating the fuzzy search algorithm
// This function specifies 0 as the maximum number of mistakes for words from 1 to 4 characters.
// It specifies 1 as the maximum number of mistakes for words from 5 to 9 characters.
// It specifies 2 as the maximum number of mistakes for words from 10 to 14 characters. And so on.

SearchResult result = index.Search(query, options); // Search in index

See Also