{"record":{"id":"d5979568caff3afd","repo":"stanfordnlp/CoreNLP","slug":"invalid-phrasecolindex","errorCode":null,"errorMessage":"Invalid phraseColIndex ","messagePattern":"Invalid phraseColIndex ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/PhraseTable.java","lineNumber":219,"sourceCode":"            throw new RuntimeException(\"Error processing field \" + i + \": '\" + columns[i] +\n                    \"' from (\" + filename + \":\" + lineno + \"): \" + line, ex);\n          }\n        } else {\n          throw new RuntimeException(\"Error processing field \" + i + \": '\" + columns[i] +\n                  \"' from + (\" + filename + \":\" + lineno + \"): \" + line);\n        }\n      }\n      addPhrase(phrase, null, counts);\n      lineno++;\n    }\n    br.close();\n    timer.done();\n  }\n\n  public void readPhrases(String filename, int phraseColIndex, int tagColIndex) throws IOException\n  {\n    if (phraseColIndex < 0) {\n      throw new IllegalArgumentException(\"Invalid phraseColIndex \" + phraseColIndex);\n    }\n    Timing timer = new Timing();\n    timer.doing(\"Reading phrases: \" + filename);\n    BufferedReader br = IOUtils.readerFromString(filename);\n    String line;\n    while ((line = br.readLine()) != null) {\n      String[] columns = tabPattern.split(line);\n      String phrase = columns[phraseColIndex];\n      String tag = (tagColIndex >= 0)? columns[tagColIndex]: null;\n      addPhrase(phrase, tag);\n    }\n    br.close();\n    timer.done();\n  }\n\n  public static Phrase getLongestPhrase(List<Phrase> phrases)\n  {\n    Phrase longest = null;","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/PhraseTable.java#L201-L237","documentation":"RuntimeException from PhraseTable.readPhrases when the phraseColIndex (or tagColIndex) argument is negative or exceeds the number of columns in the phrase file; column-based reading cannot locate the phrase (or tag) field.","triggerScenarios":"Calling readPhrases(filename, phraseColIndex, tagColIndex) with phraseColIndex < 0, typically -1 used as a 'not set' sentinel.","commonSituations":"Caller initializes the column index to -1 as a default and forgets to set it from config; off-by-one or uninitialized fields in a wrapper around PhraseTable.","solutions":["Pass a valid 0-based column index (>= 0) for the phrase column","Initialize default column indices to 0 rather than -1","Check your configuration value for the phrase column before calling"],"exampleFix":"// before\ntable.readPhrases(file, -1, 1);\n// after\ntable.readPhrases(file, 0, 1); // phrase is column 0","handlingStrategy":"validation","validationCode":"if (phraseColIndex < 0) throw new IllegalArgumentException(\"phraseColIndex must be >= 0, got \" + phraseColIndex);\ntable.readPhrases(file, phraseColIndex, tagColIndex);","typeGuard":"static boolean validColIndex(int i) { return i >= 0; }","tryCatchPattern":"try { table.readPhrases(file, col, tagCol); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Invalid phraseColIndex\")) { LOG.error(\"Configure the phrase column index\"); } throw e; }","preventionTips":["Default column indices to 0, never -1","Resolve config-driven column indexes before calling","Document that column indexes are 0-based"],"tags":["tokensregex","illegal-argument","index"],"backgroundTag":"invalid-argument-value","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"}