{"record":{"id":"9f12c1bb5f482122","repo":"languagetool-org/languagetool","slug":"could-not-load-srx-rules","errorCode":null,"errorMessage":"Could not load SRX rules","messagePattern":"Could not load SRX rules","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/tokenizers/SrxTools.java","lineNumber":60,"sourceCode":"  private static final Map<String, Object> VALIDATION_PARAMETERS = Map.of(Srx2SaxParser.VALIDATE_PARAMETER, true);\n\n  private static final Map<String, Object> TOKENIZE_PARAMETERS =\n    Map.of(SrxTextIterator.DEFAULT_PATTERN_FLAGS_PARAMETER, Pattern.UNICODE_CHARACTER_CLASS);\n\n  private SrxTools() {\n  }\n\n  static SrxDocument createSrxDocument(String path) {\n    try {\n      try (\n        InputStream inputStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(path);\n        BufferedReader srxReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))\n      ) {\n        SrxParser srxParser = new Srx2SaxParser(VALIDATION_PARAMETERS);\n        return srxParser.parse(srxReader);\n      }\n    } catch (IOException e) {\n      throw new RuntimeException(\"Could not load SRX rules\", e);\n    }\n  }\n\n  static List<String> tokenize(String text, SrxDocument srxDocument, String languageCode) {\n    List<String> segments = new ArrayList<>();\n    TextIterator textIterator = new SrxTextIterator(srxDocument, languageCode, text, TOKENIZE_PARAMETERS);\n    while (textIterator.hasNext()) {\n      segments.add(textIterator.next());\n    }\n    return segments;\n  }\n\n}","sourceCodeStart":42,"sourceCodeEnd":73,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/tokenizers/SrxTools.java#L42-L73","documentation":"The SRX segmentation rules file could not be read from the resource dir or parsed as SRX XML. createSrxDocument wraps I/O or parsing failures while building the SrxDocument used for sentence splitting; the input at fault is the SRX resource path passed in.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/tokenizers/SrxTools.java:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the SRX file exists in the classpath/resource dir at the given path","Check the SRX file is well-formed XML and valid against the SRX schema","Inspect the chained cause for the underlying IOException or SAXException"],"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"}