Class GenericUnpairedQuotesRule

Direct Known Subclasses:
EnglishUnpairedQuotesRule, GermanUnpairedQuotesRule

public class GenericUnpairedQuotesRule extends TextLevelRule
Rule that finds unpaired quotes
Since:
6.4
  • Field Details

    • POSSIBLE_APOSTROPHE

      private static final Pattern POSSIBLE_APOSTROPHE
    • INCH_PATTERN

      private static final Pattern INCH_PATTERN
    • PUNCTUATION

      private static final Pattern PUNCTUATION
    • PUNCT_MARKS

      private static final Pattern PUNCT_MARKS
    • startSymbols

      private final List<String> startSymbols
    • endSymbols

      private final List<String> endSymbols
    • ruleId

      private final String ruleId
  • Constructor Details

    • GenericUnpairedQuotesRule

      public GenericUnpairedQuotesRule(String ruleId, ResourceBundle messages, List<String> startSymbols, List<String> endSymbols)
    • GenericUnpairedQuotesRule

      public GenericUnpairedQuotesRule(ResourceBundle messages, List<String> startSymbols, List<String> endSymbols)
      Parameters:
      startSymbols - start symbols like "(" - note that the array must be of equal length as the next parameter and the sequence of starting symbols must match exactly the sequence of ending symbols.
      endSymbols - end symbols like ")"
    • GenericUnpairedQuotesRule

      public GenericUnpairedQuotesRule(ResourceBundle messages)
      Construct rule with a set of default start and end symbols: “” "" ‘’ ''
  • Method Details

    • getId

      public String getId()
      Description copied from class: Rule
      A string used to identify the rule in e.g. configuration files. This string is supposed to be unique and to stay the same in all upcoming versions of LanguageTool. It's supposed to contain only the characters A-Z and the underscore.
      Specified by:
      getId in class Rule
    • getDescription

      public String getDescription()
      Description copied from class: Rule
      A short description of the error this rule can detect, usually in the language of the text that is checked.
      Specified by:
      getDescription in class Rule
    • match

      public final RuleMatch[] match(List<AnalyzedSentence> sentences)
      Specified by:
      match in class TextLevelRule
    • isStartSymbolbefore

      private boolean isStartSymbolbefore(AnalyzedTokenReadings[] tokens, int i)
    • isNotOpenSymbol

      private boolean isNotOpenSymbol(int j, List<GenericUnpairedQuotesRule.SymbolLocator> openingQuotes)
    • isNotQuote

      private boolean isNotQuote(AnalyzedTokenReadings[] tokens, int i, int j)
    • isOpeningQuote

      private boolean isOpeningQuote(AnalyzedTokenReadings[] tokens, int i)
    • isClosingQuote

      private boolean isClosingQuote(AnalyzedTokenReadings[] tokens, int i, List<GenericUnpairedQuotesRule.SymbolLocator> openingQuotes)
    • isInchQuote

      private boolean isInchQuote(String text)
    • isNotBeginningApostrophe

      protected boolean isNotBeginningApostrophe(AnalyzedTokenReadings[] tokens, int i)
    • isNotEndingApostrophe

      protected boolean isNotEndingApostrophe(AnalyzedTokenReadings[] tokens, int i)
    • indexOfOpeningQuote

      private int indexOfOpeningQuote(List<GenericUnpairedQuotesRule.SymbolLocator> openingQuotes, String symbol)
    • addMatch

      private void addMatch(GenericUnpairedQuotesRule.SymbolLocator openingQuote, List<RuleMatch> ruleMatches)
    • removeAllOpenInnerQuotes

      private void removeAllOpenInnerQuotes(int index, List<GenericUnpairedQuotesRule.SymbolLocator> openingQuotes, List<RuleMatch> ruleMatches)
    • findCorrespondingSymbol

      protected String findCorrespondingSymbol(String symbol)
    • minToCheckParagraph

      public int minToCheckParagraph()
      Description copied from class: TextLevelRule
      Gives back the minimum number of paragraphs to check to give back a correct result. Only used by LO office extension.
      • n == -1 --> need to check full text (use only if really needed / bad performance) examples: AbstractWordCoherencyRule, GenericUnpairedBracketsRule, ...
      • n == 0 --> need only to check the current paragraph examples: MultipleWhitespaceRule, LongParagraphRule, ...
      • n >= 1 --> need only to check n paragraphs around the current paragraph examples: ParagraphRepeatBeginningRule (n == 1), WordRepeatBeginningRule (n == 2), ...
      Specified by:
      minToCheckParagraph in class TextLevelRule