Class FuzzySearchable

java.lang.Object
org.knime.core.ui.util.FuzzySearchable

public final class FuzzySearchable extends Object
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 Details

    • FuzzySearchable

      public FuzzySearchable(String name, String[] keywords)
      New instance whereby the arguments will be upper-cased by this constructor.
      Parameters:
      name - non-null name
      keywords - keywords (or null)
  • Method Details

    • contains

      public boolean contains(String uppercaseString)
      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

      public double computeSimilarity(String uppercaseQuery)
      For the given query, determine the "tanimoto bigram similarity"
      Parameters:
      uppercaseQuery -
      Returns:
      The similarity [0, 1]
    • computeNameSimilarity

      public double computeNameSimilarity(String uppercaseQuery)
      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

      public double computeKeywordSimilarity(String uppercaseQuery)
      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

      public String toString()
      Overrides:
      toString in class Object
    • computeTanimotoBiGramDistance

      public static double computeTanimotoBiGramDistance(String textA, String textB)
      Copied from the Tanimoto BiGram distance.
      Parameters:
      textA - Query A
      textB - Query B
      Returns:
      the distance value [0, 1]