stanfordnlp/CoreNLP · error · java.lang.IllegalArgumentException

Invalid phraseColIndex

Error message

Invalid phraseColIndex 

What it means

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.

Solutions

  1. Pass a valid 0-based column index (>= 0) for the phrase column
  2. Initialize default column indices to 0 rather than -1
  3. Check your configuration value for the phrase column before calling

Example fix

// before
table.readPhrases(file, -1, 1);
// after
table.readPhrases(file, 0, 1); // phrase is column 0
Defensive patterns

Strategy: validation

Validate before calling

if (phraseColIndex < 0) throw new IllegalArgumentException("phraseColIndex must be >= 0, got " + phraseColIndex);
table.readPhrases(file, phraseColIndex, tagColIndex);

Type guard

static boolean validColIndex(int i) { return i >= 0; }

Try / catch

try { table.readPhrases(file, col, tagCol); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Invalid phraseColIndex")) { LOG.error("Configure the phrase column index"); } throw e; }

Prevention

When it happens

Trigger: Calling readPhrases(filename, phraseColIndex, tagColIndex) with phraseColIndex < 0, typically -1 used as a 'not set' sentinel.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/d5979568caff3afd. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ling/tokensregex/PhraseTable.java:219

            throw new RuntimeException("Error processing field " + i + ": '" + columns[i] +
                    "' from (" + filename + ":" + lineno + "): " + line, ex);
          }
        } else {
          throw new RuntimeException("Error processing field " + i + ": '" + columns[i] +
                  "' from + (" + filename + ":" + lineno + "): " + line);
        }
      }
      addPhrase(phrase, null, counts);
      lineno++;
    }
    br.close();
    timer.done();
  }

  public void readPhrases(String filename, int phraseColIndex, int tagColIndex) throws IOException
  {
    if (phraseColIndex < 0) {
      throw new IllegalArgumentException("Invalid phraseColIndex " + phraseColIndex);
    }
    Timing timer = new Timing();
    timer.doing("Reading phrases: " + filename);
    BufferedReader br = IOUtils.readerFromString(filename);
    String line;
    while ((line = br.readLine()) != null) {
      String[] columns = tabPattern.split(line);
      String phrase = columns[phraseColIndex];
      String tag = (tagColIndex >= 0)? columns[tagColIndex]: null;
      addPhrase(phrase, tag);
    }
    br.close();
    timer.done();
  }

  public static Phrase getLongestPhrase(List<Phrase> phrases)
  {
    Phrase longest = null;

View on GitHub (pinned to 1b7edd19c4)