Class TextMatcher


  • public class TextMatcher
    extends Object
    Provides a simple way to compare two lists of tokens using basic fuzzy matching algorithms.
    • Field Detail

      • IGNORE_CASE

        public static final int IGNORE_CASE
        Flag indicating to ignore case differences.
        See Also:
        Constant Field Values
      • IGNORE_WHITESPACES

        public static final int IGNORE_WHITESPACES
        Flag indicating to ignore whitespaces differences.
        See Also:
        Constant Field Values
      • IGNORE_PUNCTUATION

        public static final int IGNORE_PUNCTUATION
        Flag indication to ignore punctuation differences.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TextMatcher

        public TextMatcher​(LocaleId locale1,
                           LocaleId locale2)
        Creates a new TextMatcher object.
        Parameters:
        locale1 - locale of the first language.
        locale2 - locale of the second language.
    • Method Detail

      • minimum

        protected static short minimum​(int value1,
                                       int value2,
                                       int value3)
        Returns the minimum value between three given values.
        Parameters:
        value1 - the first given value.
        value2 - the second given value.
        value3 - the third given value.
        Returns:
        the minimum value between three given values.
      • compare

        public int compare​(TextFragment frag1,
                           TextFragment frag2,
                           int options)
        Compare two textFragment content.
        Parameters:
        frag1 - The base fragment.
        frag2 - the fragment to compare against the base fragment.
        options - Comparison options.
        Returns:
        A score between 0 (no match) and 100 (exact match).
      • compareToBaseTokens

        public int compareToBaseTokens​(String text1,
                                       List<String> tokens1,
                                       TextFragment frag2)
        Compare a list of tokens to a TextFragment object.
        Parameters:
        text1 - the original plain text.
        tokens1 - the list of tokens.
        frag2 - the fragment to compare against list of tokens.
        Returns:
        A score between 0 (no match) and 100 (exact match).