class NumeralStressRule extends Rule {

  //map from stressed to unstressed form and unstressed to stressed form
  private final Map<String, String> suffixMap = new HashMap<>();
  // pattern to match an arabic number followed by a possible suffix
  private final Pattern numeral;
  // pattern to match an arabic number that needs stress
  private final Pattern stressedNumber;
  // pattern to match a stressed suffix
  private final Pattern stressedSuffix;

  public NumeralStressRule(ResourceBundle messages) {
    super(messages);

    String[] unstressedSfx = {
      "ος", "ου", "ο", "ον", "οι", "ων", "ους", "η", "ης", "ην", "ες", "α"
    };
    String[] stressedSfx = {
      "ός", "ού", "ό", "όν", "οί", "ών", "ούς", "ή", "ής", "ήν", "ές", "ά"
    };
    StringBuilder stressedSuffixRE = new StringBuilder();
    for (int i = 0; i < stressedSfx.length; i++) {
      if (i > 0) {
        stressedSuffixRE.append('|');
      }
      stressedSuffixRE.append(stressedSfx[i]);
      suffixMap.put(stressedSfx[i], unstressedSfx[i]);
      suffixMap.put(unstressedSfx[i], stressedSfx[i]);
    }
    StringBuilder pattern = new StringBuilder("([1-9][0-9]*)(");
    pattern.append(stressedSuffixRE);
    for (String sfx : unstressedSfx) {
      pattern.append('|').append(sfx);
    }
    pattern.append(')');

    numeral = Pattern.compile(pattern.toString());
    //we know the token can not start with 0
    stressedNumber = Pattern.compile("[0-9]*[0|2-9]0");
    stressedSuffix = Pattern.compile(stressedSuffixRE.toString());
    setCategory(new Category(new CategoryId("ORTHOGRAPHY"), "Orthography"));
    init();
  }

  private void init() {
    setLocQualityIssueType(ITSIssueType.Misspelling);
    addExamplePair(
        Example.wrong("Ο <marker>20ος</marker> αιώνας μαζί με τον 21ο αιώνα κατατάσσεται από τους ιστορικούς στη Σύγχρονη Ιστορία."),
        Example.fixed("Ο <marker>20ός</marker> αιώνας μαζί με τον 21ο αιώνα κατατάσσεται από τους ιστορικούς στη Σύγχρονη Ιστορία."));
  }

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

  @Override
  public String getDescription() {
    return "Έλεγχος τονισμού αριθμητικών";
  }

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

}

    List<RuleMatch> ruleMatches = new ArrayList<>();
    AnalyzedTokenReadings[] tokens = sentence.getTokensWithoutWhitespace();
    for (AnalyzedTokenReadings token : tokens) {
      Matcher m = numeral.matcher(token.getToken());
      if (m.matches()) {
        String number = m.group(1);
        String suffix = m.group(2);
        boolean needsStress = stressedNumber.matcher(number).matches();
        boolean hasStress = stressedSuffix.matcher(suffix).matches();
        if (needsStress != hasStress) {
          suffix = suffixMap.get(suffix);
          String suggestion = number + suffix;
          String msg = "<suggestion>" + suggestion + "</suggestion>";
          RuleMatch match = new RuleMatch(this, sentence, token.getStartPos(),
                  token.getEndPos(), msg, "Πρόβλημα ορθογραφίας");
          ruleMatches.add(match);
        }
      }
    }
    return toRuleMatchArray(ruleMatches);
  
<methods>public void <init>() ,public void <init>(java.util.ResourceBundle) ,public void addTags(List<java.lang.String>) ,public void addToneTags(List<java.lang.String>) ,public int estimateContextForSureMatch() ,public List<org.languagetool.tagging.disambiguation.rules.DisambiguationPatternRule> getAntiPatterns() ,public org.languagetool.rules.Category getCategory() ,public java.lang.String getConfigureText() ,public final List<org.languagetool.rules.CorrectExample> getCorrectExamples() ,public int getDefaultValue() ,public abstract java.lang.String getDescription() ,public int getDistanceTokens() ,public final List<org.languagetool.rules.ErrorTriggeringExample> getErrorTriggeringExamples() ,public java.lang.String getFullId() ,public abstract java.lang.String getId() ,public final List<org.languagetool.rules.IncorrectExample> getIncorrectExamples() ,public org.languagetool.rules.ITSIssueType getLocQualityIssueType() ,public int getMaxConfigurableValue() ,public int getMinConfigurableValue() ,public int getMinPrevMatches() ,public int getPriority() ,public java.lang.String getSourceFile() ,public java.lang.String getSubId() ,public List<org.languagetool.Tag> getTags() ,public List<org.languagetool.ToneTag> getToneTags() ,public java.net.URL getUrl() ,public boolean hasConfigurableValue() ,public boolean hasTag(org.languagetool.Tag) ,public boolean hasToneTag(org.languagetool.ToneTag) ,public final boolean isDefaultOff() ,public final boolean isDefaultTempOff() ,public boolean isDictionaryBasedSpellingRule() ,public boolean isGoalSpecific() ,public final boolean isOfficeDefaultOff() ,public final boolean isOfficeDefaultOn() ,public boolean isPremium() ,public abstract org.languagetool.rules.RuleMatch[] match(org.languagetool.AnalyzedSentence) throws java.io.IOException,public final void setCategory(org.languagetool.rules.Category) ,public final void setCorrectExamples(List<org.languagetool.rules.CorrectExample>) ,public final void setDefaultOff() ,public final void setDefaultOn() ,public final void setDefaultTempOff() ,public void setDistanceTokens(int) ,public final void setErrorTriggeringExamples(List<org.languagetool.rules.ErrorTriggeringExample>) ,public void setGoalSpecific(boolean) ,public final void setIncorrectExamples(List<org.languagetool.rules.IncorrectExample>) ,public void setLocQualityIssueType(org.languagetool.rules.ITSIssueType) ,public void setMinPrevMatches(int) ,public final void setOfficeDefaultOff() ,public final void setOfficeDefaultOn() ,public void setPremium(boolean) ,public void setPriority(int) ,public void setTags(List<org.languagetool.Tag>) ,public void setToneTags(List<org.languagetool.ToneTag>) ,public void setUrl(java.net.URL) ,public boolean supportsLanguage(org.languagetool.Language) ,public boolean useInOffice() <variables>private static final org.languagetool.rules.Category MISC,private org.languagetool.rules.Category category,private List<org.languagetool.rules.CorrectExample> correctExamples,private boolean defaultOff,private boolean defaultTempOff,private int distanceTokens,private List<org.languagetool.rules.ErrorTriggeringExample> errorTriggeringExamples,private List<org.languagetool.rules.IncorrectExample> incorrectExamples,private boolean isGoalSpecific,private boolean isPremium,private org.languagetool.rules.ITSIssueType locQualityIssueType,protected final non-sealed java.util.ResourceBundle messages,private int minPrevMatches,private boolean officeDefaultOff,private boolean officeDefaultOn,private int priority,private List<org.languagetool.Tag> tags,private List<org.languagetool.ToneTag> toneTags,private java.net.URL url