{"record":{"id":"f83bebd171df28de","repo":"stanfordnlp/CoreNLP","slug":"error-on-line","errorCode":null,"errorMessage":"Error on line ","messagePattern":"Error on line ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/BaseLexicon.java","lineNumber":789,"sourceCode":"    // all lines have one tagging with raw count per line\n    line = in.readLine();\n    Pattern p = Pattern.compile(\"^smooth\\\\[([0-9])\\\\] = (.*)$\");\n    while (line != null && line.length() > 0) {\n      try {\n        Matcher m = p.matcher(line);\n        if (m.matches()) {\n          int i = Integer.parseInt(m.group(1));\n          smooth[i] = Double.parseDouble(m.group(2));\n        } else {\n          // split on spaces, quote with doublequote, and escape with backslash\n          String[] fields = StringUtils.splitOnCharWithQuoting(line, ' ', '\\\"', '\\\\');\n          // System.out.println(\"fields:\\n\" + fields[0] + \"\\n\" + fields[1] +\n          // \"\\n\" + fields[2] + \"\\n\" + fields[3] + \"\\n\" + fields[4]);\n          boolean seen = fields[3].equals(SEEN);\n          addTagging(seen, new IntTaggedWord(fields[2], fields[0], wordIndex, tagIndex), Double.parseDouble(fields[4]));\n        }\n      } catch (RuntimeException e) {\n        throw new IOException(\"Error on line \" + lineNum + \": \" + line, e);\n      }\n      lineNum++;\n      line = in.readLine();\n    }\n    initRulesWithWord();\n  }\n\n  /**\n   * Writes out data from this Object to the Writer w. Rules are separated by\n   * newline, and rule elements are delimited by \\t.\n   */\n  @Override\n  public void writeData(Writer w) throws IOException {\n    PrintWriter out = new PrintWriter(w);\n\n    for (Map.Entry<IntTaggedWord, Double> entry : seenCounter.entrySet()) {\n      out.println(entry.getKey().toLexicalEntry(wordIndex, tagIndex) + \" SEEN \" + entry.getValue());\n    }","sourceCodeStart":771,"sourceCodeEnd":807,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/BaseLexicon.java#L771-L807","documentation":"BaseLexicon.readGrammaticalStructure... actually this is the lexicon text-loading path: while reading a lexicon file line by line, any RuntimeException from parsing a line (malformed fields, bad number in the weight field, missing columns) is wrapped into an IOException whose message includes the line number and the offending line, to make the corrupt input locatable.","triggerScenarios":"Loading a lexicon text file (e.g. via -textFile lexicon or readData) where a line does not have the expected 5 fields SEEN/UNSEEN word tag count — e.g. Double.parseDouble(fields[4]) fails or fields[2]/fields[0] don't split into word/tag correctly.","commonSituations":"Hand-edited lexicon files, files with header lines or blank/truncated lines, wrong file passed as the lexicon (e.g. a model binary given as text lexicon), wrong column order.","solutions":["Inspect the reported line number in the lexicon file and fix the malformed line (5 tab/whitespace-separated fields: tag, seen-flag, word, ..., count)","Check the field order matches the writer's format (tag, seen/UNSEEN, word, ..., weight)","Remove header/comment/empty lines from the lexicon file","Verify you are loading the right file type (text lexicon vs serialized model)"],"exampleFix":"// before (bad line 42: only 4 fields)\nNN  SEEN  dog  100\n// after\nNN  SEEN  dog  UNK  100","handlingStrategy":"validation","validationCode":"// validate lexicon lines before loading\nint lineNum = 0;\nfor (String line : Files.readAllLines(lexiconPath)) {\n  lineNum++;\n  String[] fields = line.trim().split(\"\\\\s+\");\n  if (fields.length != 5) throw new IOException(\"lexicon line \" + lineNum + \" has \" + fields.length + \" fields, expected 5\");\n  Double.parseDouble(fields[4]);\n}","typeGuard":null,"tryCatchPattern":"try {\n  lexicon.loadFile(lexiconPath);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Error on line\")) {\n    System.err.println(\"Fix the cited lexicon line: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Never hand-edit lexicon files without preserving the 5-field format","Strip headers, comments, and blank lines before loading","Confirm the file is the text lexicon format, not a serialized model","Keep the original writer's field order (tag, seen flag, word, ..., count)"],"tags":["java","io","lexicon","file-parse","stanford-parser"],"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-15T23:17:13.987Z"}