net.sf.okapi.lib.translation

## Class TextMatcher

- java.lang.Object
- - net.sf.okapi.lib.translation.TextMatcher

-     public class TextMatcher
      extends java.lang.Object

  Provides a simple way to compare two lists of tokens using basic fuzzy matching algorithms.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `IGNORE_CASE` Flag indicating to ignore case differences.
    `static int` | `IGNORE_PUNCTUATION` Flag indication to ignore punctuation differences.
    `static int` | `IGNORE_WHITESPACES` Flag indicating to ignore whitespaces differences.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TextMatcher(LocaleId locale1, LocaleId locale2)` Creates a new TextMatcher object.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(TextFragment frag1, TextFragment frag2, int options)` Compare two textFragment content.
    `int` | `compareToBaseTokens(java.lang.String text1, java.util.List<java.lang.String> tokens1, TextFragment frag2)` Compare a list of tokens to a `TextFragment` object.
    `protected static short` | `minimum(int value1, int value2, int value3)` Returns the minimum value between three given values.
    `java.util.List<java.lang.String>` | `prepareBaseTokens(java.lang.String plainText)` Creates a list of tokens from a string to use with the `compareToBaseTokens(String, List, TextFragment)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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).

    - #### prepareBaseTokens

          public java.util.List<java.lang.String> prepareBaseTokens(java.lang.String plainText)

      Creates a list of tokens from a string to use with the `compareToBaseTokens(String, List, TextFragment)`.
      Parameters:
        `plainText` - the based text.
      Returns:
        the list of tokens for the given fragment.

    - #### compareToBaseTokens

          public int compareToBaseTokens(java.lang.String text1,
                                         java.util.List<java.lang.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).