{"record":{"id":"c5da20e32028f69c","repo":"languagetool-org/languagetool","slug":"error-trying-to-synthesize-pos-tag-postag","errorCode":null,"errorMessage":"Error trying to synthesize POS tag \" + posTag + \" (posTagRegExp: true) from token \" + token.getToken()","messagePattern":"Error trying to synthesize POS tag \" \\+ posTag \\+ \" \\(posTagRegExp: true\\) from token \" \\+ token\\.getToken\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/synthesis/BaseSynthesizer.java","lineNumber":261,"sourceCode":"    }\n    if (posTag.equals(SPELLNUMBER_FEMININE_TAG)) {\n      return new String[] {getSpelledNumber(\"feminine \" + token.getToken())};\n    }\n    if (posTag.equals(SPELLNUMBER_ROMAN_TAG)) {\n      return new String[] {getRomanNumber(token.getToken())};\n    }\n    List<String> wordForms = lookup(token.getLemma(), posTag);\n    return removeExceptions(wordForms.toArray(new String[0]));\n  }\n\n  @Override\n  public String[] synthesize(AnalyzedToken token, String posTag, boolean posTagRegExp) throws IOException {\n    if (posTagRegExp) {\n      try {\n        Pattern p = Pattern.compile(posTag);\n        return synthesizeForPosTags(token.getLemma(), tag -> p.matcher(tag).matches());\n      } catch (PatternSyntaxException e) {\n        throw new RuntimeException(\"Error trying to synthesize POS tag \" + posTag +\n                \" (posTagRegExp: true) from token \" + token.getToken(), e);\n      }\n    }\n    return removeExceptions(synthesize(token, posTag));\n  }\n\n  /**\n   * Synthesize forms for the given lemma and for all POS tags satisfying the given predicate.\n   * @since 5.3\n   */\n  public String[] synthesizeForPosTags(String lemma, Predicate<String> acceptTag) throws IOException {\n    initPossibleTags();\n    List<String> results = new ArrayList<>();\n    for (String tag : possibleTags) {\n      if (acceptTag.test(tag)) {\n        results.addAll(lookup(lemma, tag));\n      }\n    }","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/synthesis/BaseSynthesizer.java#L243-L279","documentation":"Wrapper exception in BaseSynthesizer.synthesize for the posTagRegExp=true code path: treating the POS tag as a regular expression and synthesizing matching word forms failed unexpectedly, and the error is rethrown with the offending tag and token attached. The inputs at fault are the POS-tag pattern and the analyzed token passed by the calling rule.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/synthesis/BaseSynthesizer.java:261 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the chained cause to find the underlying failure (often an invalid regex in the POS tag)","Simplify the POS-tag regular expression to isolate the failing construct","Test the tag pattern against the synthesizer's list of possible tags to confirm it matches something"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}