TableDiscreteFunction
Contents
[
Hide
]
Inheritance: java.lang.Object, com.groupdocs.search.options.FuzzyAlgorithm
public class TableDiscreteFunction extends FuzzyAlgorithm
Represents the fuzzy search algorithm that contains correspondences between word lengths and the number of allowed mistakes. This algorithm can be specified by a table of output values or by a step function.
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 TableDiscreteFunction(1, new Step(5, 2), new Step(8, 3))); // Creating the fuzzy search algorithm
// This function specifies 1 as the maximum number of mistakes for words from 1 to 4 characters.
// It specifies 2 as the maximum number of mistakes for words from 5 to 7 characters.
// It specifies 3 as the maximum number of mistakes for words from 8 and more characters.
SearchResult result = index.search(query, options); // Search in index
Constructors
Constructor | Description |
---|---|
TableDiscreteFunction(int offsetOfInputs, int[] tableOfOutputs) | Initializes a new instance of the TableDiscreteFunction class. |
TableDiscreteFunction(int firstStepLevel, Step[] steps) | Initializes a new instance of the TableDiscreteFunction class. |
Methods
Method | Description |
---|---|
getSimilarityLevel(int termLength) | Gets a similarity level for specified term length. |
getMaxMistakeCount(int termLength) | Gets a maximum allowed number of mistakes for specified term length. |
TableDiscreteFunction(int offsetOfInputs, int[] tableOfOutputs)
public TableDiscreteFunction(int offsetOfInputs, int[] tableOfOutputs)
Initializes a new instance of the TableDiscreteFunction class.
Parameters:
Parameter | Type | Description |
---|---|---|
offsetOfInputs | int | The offset of the table indeces relative to the input values. |
tableOfOutputs | int[] | The table of output values. |
TableDiscreteFunction(int firstStepLevel, Step[] steps)
public TableDiscreteFunction(int firstStepLevel, Step[] steps)
Initializes a new instance of the TableDiscreteFunction class.
Parameters:
Parameter | Type | Description |
---|---|---|
firstStepLevel | int | The level of the first step of the step function. |
steps | Step[] | The next steps of the step function. |
getSimilarityLevel(int termLength)
public double getSimilarityLevel(int termLength)
Gets a similarity level for specified term length.
Parameters:
Parameter | Type | Description |
---|---|---|
termLength | int | The term length. |
Returns: double - A similarity level.
getMaxMistakeCount(int termLength)
public int getMaxMistakeCount(int termLength)
Gets a maximum allowed number of mistakes for specified term length.
Parameters:
Parameter | Type | Description |
---|---|---|
termLength | int | The term length. |
Returns: int - A maximum allowed number of mistakes.