Class BitextRule

java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.bitext.BitextRule
Direct Known Subclasses:
BitextPatternRule, DifferentLengthRule, DifferentPunctuationRule, SameTranslationRule

public abstract class BitextRule extends Rule
Abstract bitext rule class. A BitextRule describes a language error and can test whether a given pre-analyzed pair of source and target text contains that error using the Rule.match(org.languagetool.AnalyzedSentence) method.
  • Field Details

  • Constructor Details

    • BitextRule

      public BitextRule()
  • Method Details

    • getRelevantRules

      public static List<Class<? extends BitextRule>> getRelevantRules()
    • getMessage

      public abstract String getMessage()
    • match

      public abstract RuleMatch[] match(AnalyzedSentence sourceText, AnalyzedSentence targetText) throws IOException
      Throws:
      IOException
    • match

      @Nullable public @Nullable RuleMatch[] match(AnalyzedSentence sentence) throws IOException
      This method makes no sense for bitext, thus it always returns null.
      Specified by:
      match in class Rule
      Parameters:
      sentence - a pre-analyzed sentence
      Returns:
      an array of RuleMatch objects
      Throws:
      IOException
    • setSourceLanguage

      public final void setSourceLanguage(Language lang)
      Set the source language. If the language is not supported by LT, you need to use the default tokenizers etc.
      Parameters:
      lang - Source Language
    • getSourceLanguage

      public final Language getSourceLanguage()
    • setCorrectBitextExamples

      public final void setCorrectBitextExamples(List<StringPair> correctExamples)
      Set the examples that are correct and thus do not trigger the rule.
    • getCorrectBitextExamples

      public final List<StringPair> getCorrectBitextExamples()
      Get example sentences that are correct and thus will not match this rule.
    • setIncorrectBitextExamples

      public final void setIncorrectBitextExamples(List<IncorrectBitextExample> incorrectExamples)
      Set the examples that are incorrect and thus do trigger the rule.
    • getIncorrectBitextExamples

      public final List<IncorrectBitextExample> getIncorrectBitextExamples()
      Get example sentences that are incorrect and thus will match this rule.