{"record":{"id":"48268bc5f294d71e","repo":"languagetool-org/languagetool","slug":"could-not-load-simple-replacement-data-from-p","errorCode":null,"errorMessage":"Could not load simple replacement data from: \" + path + \". Error in line '\" + line + \"', expected format 'word=replacement'","messagePattern":"Could not load simple replacement data from: \" \\+ path \\+ \"\\. Error in line '\" \\+ line \\+ \"', expected format 'word=replacement'","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/SimpleReplaceDataLoader.java","lineNumber":49,"sourceCode":" * @since 3.0\n */\npublic final class SimpleReplaceDataLoader {\n\n  /**\n   * Load replacement rules from a utf-8 file in the classpath.\n   */\n  public Map<String, List<String>> loadWords(String path) {\n    InputStream stream = JLanguageTool.getDataBroker().getFromRulesDirAsStream(path);\n    Map<String, List<String>> map = new HashMap<>();\n    try (Scanner scanner = new Scanner(stream, \"utf-8\")) {\n      while (scanner.hasNextLine()) {\n        String line = scanner.nextLine();\n        if (line.isEmpty() || line.charAt(0) == '#') { // # = comment\n          continue;\n        }\n        String[] parts = line.split(\"=\");\n        if (parts.length != 2) {\n          throw new RuntimeException(\"Could not load simple replacement data from: \" + path + \". \" +\n                  \"Error in line '\" + line + \"', expected format 'word=replacement'\");\n        }\n        if (parts[1].trim().isEmpty()) {\n          throw new RuntimeException(\"Could not load simple replacement data from: \" + path + \". \" +\n            \"Error in line '\" + line + \"', replacement cannot be empty\");\n        }\n        String[] wrongForms = parts[0].split(\"\\\\|\");\n        List<String> replacements = Arrays.asList(parts[1].split(\"\\\\|\"));\n        for (String wrongForm : wrongForms) {\n          map.put(wrongForm, replacements);\n        }\n      }\n    }\n    return Collections.unmodifiableMap(map);\n  }\n\n}\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/SimpleReplaceDataLoader.java#L31-L67","documentation":"SimpleReplaceDataLoader.loadWords reads a simple-replacement file where every non-comment line must be exactly 'word=replacement' (split('=') must yield exactly 2 parts). A line with no '=' or multiple '=' signs triggers this RuntimeException naming the file and offending line.","triggerScenarios":"Calling loadWords/loadFromPath on a replacement data file containing a non-empty, non-comment line without exactly one '=' separator (e.g. 'word replacement' or 'a=b=c').","commonSituations":"Hand-editing replacement files and using spaces instead of '=', a second '=' in a value (URLs, attribute=value pairs), saved files with comment markers other than '#', or wrong file loaded.","solutions":["Fix the line reported in the message: it must contain exactly one '=' separating word and replacement (escape or rewrite values containing '=').","Comment out or remove non-data lines; only lines starting with '#' are comments.","If the replacement value legitimately contains '=', restructure the data or preprocess the loader input.","Validate the file (each non-comment line matches ^[^#=]+=.*$) before loading."],"exampleFix":"// before (data file line)\nquestion mark = ?\n// after\nquestion mark=?","handlingStrategy":"validation","validationCode":"int i = 0;\nfor (String line : Files.readAllLines(Paths.get(path))) {\n  i++;\n  if (line.isEmpty() || line.startsWith(\"#\")) continue;\n  String[] parts = line.split(\"=\");\n  if (parts.length != 2 || parts[1].trim().isEmpty()) {\n    throw new IllegalStateException(\"Bad replacement line \" + i + \" in \" + path + \": '\" + line + \"'\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  data = SimpleReplaceDataLoader.loadFromPath(path);\n} catch (RuntimeException e) {\n  LOG.error(\"Replacement file invalid: {}\", e.getMessage());\n  throw e;\n}","preventionTips":["Use exactly one '=' per line; no spaces around it unless intended","Only '#' lines are comments — remove or reformat other annotations","Pre-validate replacement files in CI","Avoid values containing '=' or restructure the data if unavoidable"],"tags":["java","languagetool","data-file-format","replacement-rules"],"backgroundTag":"invalid-argument-format","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"}