Package org.knime.core.ui.util
Class FuzzySearchable
java.lang.Object
org.knime.core.ui.util.FuzzySearchable
A utility class to calculate the tanimoto bi-gram similarity, originally copied from the Tanimoto BiGram distance
from the distmatrix package. (Searching the web for bi-gram and jaccard will give plenty of hits.)
- Since:
- 5.0
- Author:
- Marcel Hanser, KNIME AG, Zurich, Switzerland
-
Constructor Summary
ConstructorsConstructorDescriptionFuzzySearchable(String name, String[] keywords) New instance whereby the arguments will be upper-cased by this constructor. -
Method Summary
Modifier and TypeMethodDescriptiondoublecomputeKeywordSimilarity(String uppercaseQuery) Computes the "tanimoto bigram similarity" between given query and the searchable keywords.doublecomputeNameSimilarity(String uppercaseQuery) Computes the "tanimoto bigram similarity" between given query and searchable name.doublecomputeSimilarity(String uppercaseQuery) For the given query, determine the "tanimoto bigram similarity"static doublecomputeTanimotoBiGramDistance(String textA, String textB) Copied from the Tanimoto BiGram distance.booleantoString()
-
Constructor Details
-
FuzzySearchable
New instance whereby the arguments will be upper-cased by this constructor.- Parameters:
name- non-null namekeywords- keywords (or null)
-
-
Method Details
-
contains
- Parameters:
uppercaseString- querystring - all caps (required here since otherwise the case conversion would be done for _all_ instances of "FuzzySearchable" (aka nodes))- Returns:
- If either the name or any of the keywords contain the query
-
computeSimilarity
For the given query, determine the "tanimoto bigram similarity"- Parameters:
uppercaseQuery-- Returns:
- The similarity [0, 1]
-
computeNameSimilarity
Computes the "tanimoto bigram similarity" between given query and searchable name.- Parameters:
uppercaseQuery- query- Returns:
- a similarity value between the given query and the searchable name in [0, 1]
-
computeKeywordSimilarity
Computes the "tanimoto bigram similarity" between given query and the searchable keywords.- Parameters:
uppercaseQuery- query- Returns:
- a similarity value between the given query and the searchable keywords in [0, 1]
-
toString
-
computeTanimotoBiGramDistance
Copied from the Tanimoto BiGram distance.- Parameters:
textA- Query AtextB- Query B- Returns:
- the distance value [0, 1]
-