public class SimilarityLevel extends FuzzyAlgorithm
Learn more
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.getFuzzySearch().setEnabled(true); // Enabling the fuzzy search
options.getFuzzySearch().setFuzzyAlgorithm(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
Constructor and Description |
---|
SimilarityLevel(double value)
Initializes a new instance of the
SimilarityLevel class. |
Modifier and Type | Method and Description |
---|---|
protected static int |
getByteCount(SimilarityLevel algorithm) |
int |
getMaxMistakeCount(int termLength)
Gets the maximum allowed number of mistakes for the specified term length.
|
double |
getSimilarityLevel(int termLength)
Gets the similarity level value for the specified term length.
|
protected static double |
getValue(SimilarityLevel algorithm) |
protected static void |
toByteArray(SimilarityLevel algorithm,
ArrayWriter writer) |
createProtected
public SimilarityLevel(double value)
SimilarityLevel
class.value
- The similarity level value.protected static double getValue(SimilarityLevel algorithm)
public double getSimilarityLevel(int termLength)
getSimilarityLevel
in class FuzzyAlgorithm
termLength
- The term length.public int getMaxMistakeCount(int termLength)
getMaxMistakeCount
in class FuzzyAlgorithm
termLength
- The term length.protected static int getByteCount(SimilarityLevel algorithm)
protected static void toByteArray(SimilarityLevel algorithm, ArrayWriter writer)