class StyleRepeatedSentenceBeginning extends TextLevelRule {
  
  public StyleRepeatedSentenceBeginning(ResourceBundle messages) {
    super(messages);
    super.setCategory(new Category(new CategoryId("CREATIVE_WRITING"), 
        messages.getString("category_creative_writing"), Location.INTERNAL, false));
    setDefaultOff();
    setLocQualityIssueType(ITSIssueType.Style);
    addExamplePair(Example.wrong("<marker>Das Auto</marker> kam näher. <marker>Der Hund</marker> lief langsam über die Straße. <marker>Die Reifen</marker> quietschten."),
                   Example.fixed("Das Auto kam näher. Langsam lief der Hund über die Straße. Die Reifen quietschten."));
  }

  private final static int MIN_REPEATED = 3;

  @Override
  public RuleMatch[] match(List<AnalyzedSentence> sentences) throws IOException {<FILL_FUNCTION_BODY>}

  @Override
  public int minToCheckParagraph() {
    return MIN_REPEATED;
  }

  @Override
  public String getId() {
    return "STYLE_REPEATED_SENTENCE_BEGINNING";
  }

  @Override
  public String getDescription() {
    return "Subjekt als wiederholter Satzanfang";
  }

}

    List<RuleMatch> ruleMatches = new ArrayList<>();
    if (sentences.size() < MIN_REPEATED) {
      return toRuleMatchArray(ruleMatches);
    }
    List<Integer> startPos = new ArrayList<>();
    List<Integer> endPos = new ArrayList<>();
    List<AnalyzedSentence> repeatedSentences = new ArrayList<>();
    int pos = 0;
    int nRepeated = 0;
    for (AnalyzedSentence sentence : sentences) {
      AnalyzedTokenReadings[] tokens = sentence.getTokensWithoutWhitespace();
      if (tokens[1].hasPosTagStartingWith("ART:DEF:NOM") || tokens[1].hasPosTagStartingWith("ART:IND:NOM")) {
        boolean noSub = true;
        for (int i = 2; i < tokens.length && !tokens[i].hasPosTagStartingWith("VER"); i++) {
          if (tokens[i].hasPosTagStartingWith("SUB")) {
            noSub = false;
            endPos.add(tokens[i].getEndPos() + pos);
            break;
          }
        }
        if (noSub) {
          endPos.add(tokens[1].getEndPos() + pos);
        }
        repeatedSentences.add(sentence);
        startPos.add(tokens[1].getStartPos() + pos);
        nRepeated++;
      } else if (tokens[1].hasPosTagStartingWith("PRO:PER:NOM")) {
        repeatedSentences.add(sentence);
        startPos.add(tokens[1].getStartPos() + pos);
        endPos.add(tokens[1].getEndPos() + pos);
        nRepeated++;
      } else {
        if (nRepeated >= MIN_REPEATED) {
          for (int i = 0; i < repeatedSentences.size(); i++) {
            RuleMatch ruleMatch = new RuleMatch(this, repeatedSentences.get(i), startPos.get(i), endPos.get(i), getDescription());
            ruleMatches.add(ruleMatch);
          }
        }
        repeatedSentences.clear();
        startPos.clear();
        endPos.clear();
        nRepeated = 0;
      }
      pos += sentence.getCorrectedTextLength();
    }
    if (nRepeated >= MIN_REPEATED) {
      for (int i = 0; i < repeatedSentences.size(); i++) {
        RuleMatch ruleMatch = new RuleMatch(this, repeatedSentences.get(i), startPos.get(i), endPos.get(i), getDescription());
        ruleMatches.add(ruleMatch);
      }
    }
    return toRuleMatchArray(ruleMatches);
  
<methods>public void <init>() ,public void <init>(java.util.ResourceBundle) ,public int estimateContextForSureMatch() ,public org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence>, org.languagetool.markup.AnnotatedText) throws java.io.IOException,public abstract org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence>) throws java.io.IOException,public final org.languagetool.rules.RuleMatch[] match(org.languagetool.AnalyzedSentence) throws java.io.IOException,public abstract int minToCheckParagraph() <variables>