Class FindMatches

java.lang.Object
org.omegat.core.statistics.FindMatches

public class FindMatches extends Object
Class to find matches by specified criteria.

Since we can use stemmers to prepare tokens, we should use 3-pass comparison of similarity. Similarity will be calculated in 3 steps:

  1. Split the original segment into word-only tokens using stemmer (with stop words list), then compare tokens.
  2. Split the original segment into word-only tokens without a stemmer, then compare tokens.
  3. Split the original segment into not-only-words tokens (including numbers and tags) without a stemmer, then compare tokens.

This class is not thread safe! Must be used in the one thread only.

  • Constructor Details

    • FindMatches

      @Deprecated(since="6.1.0") public FindMatches(IProject project, int maxCount, boolean allowSeparateSegmentMatch, boolean searchExactlyTheSame)
      Deprecated.
      Constructs a FindMatches instance for finding fuzzy matched translation memories.
      Parameters:
      project - OmegaT project.
      maxCount - Limits the maximum count of the results.
      allowSeparateSegmentMatch - Specifies whether to allow separate segment matching.
      searchExactlyTheSame - Allows searching for similarities with the exact same text as the source segment. This mode is used specifically for separate sentence match in paragraph-based projects, where the source is part of the current segment.
    • FindMatches

      public FindMatches(IProject project, Segmenter segmenter, int maxCount, boolean searchExactlyTheSame, int threshold)
      FindMatches find fuzzy matched translation memories.
      Parameters:
      project - OmegaT project.
      segmenter - used when running a segmentation search.
      maxCount - limit the maximum count of the results.
      searchExactlyTheSame - allows searching similarities with the same text as a source segment. This mode is used only for separate sentence match in a paragraph project, i.e., where a source is just part of the current source.
      threshold - threshold to use.
  • Method Details

    • search

      @Deprecated(since="6.1.0") public List<NearString> search(String searchText, boolean requiresTranslation, boolean fillSimilarityData, IStopped stop) throws FindMatches.StoppedException
      Deprecated.
      Searches for translation matches in the translation memory.
      Parameters:
      searchText - The target segment or term to search for.
      requiresTranslation - Indicates whether only translations are required during the search.
      fillSimilarityData - Specifies whether similarity data should be included in the resulting NearString objects.
      stop - The IStopped callback object to handle cancellation of the search process.
      Returns:
      A list of NearString objects representing the matched translation entries.
      Throws:
      FindMatches.StoppedException - Thrown if the search process is stopped by the IStopped callback.
    • search

      public List<NearString> search(String searchText, boolean fillSimilarityData, IStopped stop) throws FindMatches.StoppedException
      Search Translation memories.
      Parameters:
      searchText - The target segment or term to search for.
      fillSimilarityData - Specifies whether similarity data should be filled into the result of NearString objects.
      stop - IStopped callback object to indicate cancel operation.
      Returns:
      List of NearString objects, which hold matched translation entry.
      Throws:
      FindMatches.StoppedException - raised when stopped during a search process.
    • processEntry

      public void processEntry(EntryKey key, ITMXEntry entry, String tmxName, NearString.MATCH_SOURCE comesFrom, boolean fuzzy, int penalty)
      Compare one entry with the original entry.
      Parameters:
      key - entry to compare
      entry - PrepareTMXEntry entry to process.
      comesFrom - match source
      fuzzy - is it fuzzy or not
      penalty - penalty score
      tmxName - tmx name