class ErrorSentence {

  private final String markupText;
  private final AnnotatedText annotatedText;
  private final List<Error> errors;

  ErrorSentence(String markupText, AnnotatedText annotatedText, List<Error> errors) {
    this.markupText = markupText;
    this.annotatedText = annotatedText;
    this.errors = errors;
  }

  public boolean hasErrorCoveredByMatchAndGoodFirstSuggestion(RuleMatch match) {
    if (hasErrorCoveredByMatch(match)) {
      List<String> suggestion = match.getSuggestedReplacements();
      if (suggestion.size() > 0) {
        String firstSuggestion = suggestion.get(0);
        for (Error error : errors) {
          // The correction from AtD might be "an hour", whereas the error might just span the wrong "a",
          // so we just apply the suggestion and see if what we get is the perfect result as specified
          // by the corpus:
          String correctedByCorpus = error.getAppliedCorrection(markupText);
          String correctedByRuleMarkup = markupText.substring(0, match.getFromPos()) +
                  match.getSuggestedReplacements().get(0) + markupText.substring(match.getToPos());
          String correctedByRule = correctedByRuleMarkup.replaceAll("<.*?>", "");
          if (correctedByRule.equals(correctedByCorpus)) {
            return true;
          }
          if (error.getCorrection().equalsIgnoreCase(firstSuggestion)) {
            return true;
          }
        }
      }
    }
    return false;
  }

  public boolean hasErrorCoveredByMatch(RuleMatch match) {
    for (Error error : errors) {
      if (match.getFromPos() <= error.getStartPos() && match.getToPos() >= error.getEndPos()) {
        return true;
      }
    }
    return false;
  }

  /** @since 3.2 */
  public boolean hasErrorOverlappingWithMatch(RuleMatch match) {<FILL_FUNCTION_BODY>}

  public String getMarkupText() {
    return markupText;
  }

  public AnnotatedText getAnnotatedText() {
    return annotatedText;
  }

  public List<Error> getErrors() {
    return errors;
  }

  @Override
  public String toString() {
    return markupText;
  }
}

    for (Error error : errors) {
      if (match.getFromPos() <= error.getStartPos() && match.getToPos() >= error.getEndPos() ||
          match.getFromPos() >= error.getStartPos() && match.getFromPos() <= error.getEndPos() ||
          match.getToPos() >= error.getStartPos() && match.getToPos() <= error.getEndPos()) {
        return true;
      }
    }
    return false;
  
<no_super_class>