class SimilarNameRule extends TextLevelRule {

  private static final int MIN_LENGTH = 4;
  private static final int MAX_DIFF = 1;
  
  public SimilarNameRule(ResourceBundle messages) {
    super(messages);
    super.setCategory(Categories.TYPOS.getCategory(messages));
    addExamplePair(Example.wrong("Angela Müller ist CEO. <marker>Miller</marker> wurde in Hamburg geboren."),
                   Example.fixed("Angela Müller ist CEO. <marker>Müller</marker> wurde in Hamburg geboren."));
    setDefaultOff();
  }

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

  @Override
  public String getDescription() {
    return "Mögliche Tippfehler in Namen finden";
  }

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

  @Nullable
  private String similarName(String nameHere, Set<String> namesSoFar) {
    for (String name : namesSoFar) {
      if (name.equals(nameHere)) {
        continue;
      }
      int lenDiff = Math.abs(name.length() - nameHere.length());
      boolean nameEndsWithS = name.endsWith("s") && !nameHere.endsWith("s");
      boolean otherNameEndsWithS = !name.endsWith("s") && nameHere.endsWith("s");
      boolean nameEndsWithN = name.endsWith("n") && !nameHere.endsWith("n");   // probably a dative
      boolean otherNameEndsWithN = !name.endsWith("n") && nameHere.endsWith("n");
      if (nameEndsWithS || otherNameEndsWithS || nameEndsWithN || otherNameEndsWithN) {
        // we assume this is a genitive, e.g. "Angela Merkels Ehemann"
        continue;
      }
      if (lenDiff <= MAX_DIFF && StringUtils.getLevenshteinDistance(name, nameHere) <= MAX_DIFF) {
        return name;
      }
    }
    return null;
  }

  @Override
  public int minToCheckParagraph() {
    return -1;
  }
  
}

    Set<String> namesSoFar = new HashSet<>();
    List<RuleMatch> ruleMatches = new ArrayList<>();
    int pos = 0;
    for (AnalyzedSentence sentence : sentences) {
      AnalyzedTokenReadings[] tokens = sentence.getTokensWithoutWhitespace();
      for (AnalyzedTokenReadings token : tokens) {
        String word = token.getToken();
        // not tagged = too many correct words are not known so we cannot use that:
        //boolean isName = word.length() > MIN_LENGTH && (token.hasPartialPosTag("EIG:") || !token.isTagged());
        boolean isMaybeName = word.length() >= MIN_LENGTH 
                && ((token.hasPartialPosTag("EIG:") && !token.hasPartialPosTag(":COU")) || token.isPosTagUnknown())
                && !word.equals("Dein") && !word.equals("Deine") && !word.equals("Deinen") && !word.equals("Deiner") && !word.equals("Deines") && !word.equals("Deinem")
                && !word.equals("Ihr") && !word.equals("Ihre") && !word.equals("Ihren") && !word.equals("Ihrer") && !word.equals("Ihres") && !word.equals("Ihrem");
        if (isMaybeName && StringTools.startsWithUppercase(word)) {
          String similarName = similarName(word, namesSoFar);
          if (similarName != null) {
            String msg = "'" + word + "' ähnelt dem vorher benutzten '" + similarName + "', handelt es sich evtl. um einen Tippfehler?";
            RuleMatch ruleMatch = new RuleMatch(this, sentence, pos+token.getStartPos(), pos+token.getEndPos(), msg);
            ruleMatch.setSuggestedReplacement(similarName);
            ruleMatches.add(ruleMatch);
          }
          namesSoFar.add(word);
        }
      }
      pos += sentence.getCorrectedTextLength();
    }
    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>