{"record":{"id":"253b22fe90da0dd9","repo":"stanfordnlp/CoreNLP","slug":"invalid-dictionary-line-line","errorCode":null,"errorMessage":"Invalid dictionary line: ${line}","messagePattern":"Invalid dictionary line: (.+?)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/machinereading/common/StringDictionary.java","lineNumber":169,"sourceCode":"  public void clear() {\n    mDict.clear();\n    mInverse.clear();\n  }\n\n  public Set<String> keySet() {\n    return mDict.keySet();\n  }\n\n  /** Loads all saved dictionary entries from disk */\n  public void load(String path, String prefix) throws java.io.IOException {\n\n    String fileName = path + java.io.File.separator + prefix + \".\" + mName;\n    try (BufferedReader is = IOUtils.readerFromString(fileName)) {\n\n      for (String line; (line = is.readLine()) != null; ) {\n        ArrayList<String> tokens = SimpleTokenize.tokenize(line);\n        if (tokens.size() != 3) {\n          throw new RuntimeException(\"Invalid dictionary line: \" + line);\n        }\n        int index = Integer.parseInt(tokens.get(1));\n        int count = Integer.parseInt(tokens.get(2));\n        if (index < 0 || count <= 0) {\n          throw new RuntimeException(\"Invalid dictionary line: \" + line);\n        }\n\n        IndexAndCount ic = new IndexAndCount(index, count);\n        mDict.put(tokens.get(0), ic);\n        mInverse.put(Integer.valueOf(index), tokens.get(0));\n      }\n\n      log.info(\"Loaded \" + mDict.size() + \" entries for dictionary \\\"\" + mName + \"\\\".\");\n    }\n  }\n\n  public java.util.Set<String> keys() {\n    return mDict.keySet();","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/machinereading/common/StringDictionary.java#L151-L187","documentation":"When load() reads a saved dictionary file, each line must tokenize into exactly 3 fields (word, index, count). If a line has a different field count, load() throws this RuntimeException, indicating the dictionary file is malformed.","triggerScenarios":"load(path, prefix) encountering a dictionary line where SimpleTokenize.tokenize yields != 3 tokens — e.g. a word containing an unquoted space, an edited/truncated file, or a manually written dictionary entry missing the index or count column.","commonSituations":"Hand-edited .dict files, files saved by a different tool or format version, copy-paste corruption, CRLF/encoding issues that merge or split fields.","solutions":["Open the dictionary file at the reported location and fix or remove the malformed line.","Regenerate the dictionary file from source data via save() instead of editing it by hand.","Check that the file is whitespace-tokenizable with SimpleTokenize: quote/escape spaces in words or use the format the saver emits.","Confirm you are loading the file produced by the same format version."],"exampleFix":"// before (bad line)\nParis 12\n// after\nParis 12 5","handlingStrategy":"validation","validationCode":"for (String line : Files.readAllLines(path)) {\n  String[] t = line.trim().split(\"\\\\s+\");\n  if (t.length != 3) throw new IllegalStateException(\"bad dictionary line: \" + line);\n}","typeGuard":null,"tryCatchPattern":"try { dict.load(path, prefix); } catch (RuntimeException e) { logger.severe(\"malformed dictionary \" + prefix + \": \" + e.getMessage()); throw e; }","preventionTips":["Never hand-edit dictionary files; regenerate them with save().","Validate line format (3 whitespace-separated fields) before load().","Keep dictionary files versioned with the corpus that produced them."],"tags":["java","stanford-nlp","file-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}