class WordCoherencyRule extends AbstractWordCoherencyRule {

  private final static Map<String, Set<String>> wordMap = new WordCoherencyDataLoader().loadWords("/ca/coherency.txt");
  private final Synthesizer synth = Languages.getLanguageForShortCode("ca").getSynthesizer();
  private final Pattern allowedPostags = java.util.regex.Pattern.compile("[VAND].*");

  public WordCoherencyRule(ResourceBundle messages) throws IOException {
    super(messages);
    this.setCategory(Categories.STYLE.getCategory(messages));
    addExamplePair(Example.wrong("Un <marker>pesebre</marker> ací i un altre <marker>pessebre</marker> allà."),
      Example.fixed("Un <marker>pesebre</marker> ací i un altre <marker>pesebre</marker> allà."));
  }

  @Override
  protected Map<String, Set<String>> getWordMap() {
    return wordMap;
  }

  @Override
  protected String getMessage(String word1, String word2) {
    return "No és coherent usar '" + word1 + "' i '" + word2 + "' dins d'un mateix text.";
  }

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

  @Override
  public String getShortMessage() {
    return "Coherència";
  }

  @Override
  public String getDescription() {
    return "Detecta l'ús incoherent de diferents formes dins d'un text.";
  }

  protected String createReplacement(String marked, String token, String otherSpelling, AnalyzedTokenReadings atrs) {<FILL_FUNCTION_BODY>}

}

    String[] synthesizedForms;
    AnalyzedToken atr = atrs.readingWithTagRegex(allowedPostags);
    if (atr != null) {
      try {
        synthesizedForms = synth.synthesize(new AnalyzedToken("", "", otherSpelling), atr.getPOSTag());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      if (synthesizedForms != null && synthesizedForms.length > 0) {
        return synthesizedForms[0];
      }
    }
    return super.createReplacement(marked, token, otherSpelling, atrs);
  
<methods>public void <init>(java.util.ResourceBundle) throws java.io.IOException,public org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence>) ,public int minToCheckParagraph() <variables>