stanfordnlp/CoreNLP · error · java.lang.RuntimeException

Error processing field : '' from (:):

Error message

Error processing field : '' from (:): 

What it means

PhraseTable.readPhrasesWithTagScores parses lines of 'phrase<TAB>tag:count ...'. If the tag:count field has two parts but the count part is not a parsable double, NumberFormatException is wrapped and rethrown as 'Error processing field i: ... from (file:line)'.

Solutions

  1. Fix the offending file line (file:line is in the message) so the count is a plain double (e.g. 'NN:12' or 'NN:12.5')
  2. Normalize the count delimiter/format before loading (strip commas, use '.' decimal separator)
  3. Pre-validate lines in your loader: attempt Double.parseDouble on the count segment and log bad lines

Example fix

// before (file line)
hello	NN:1,234
// after
hello	NN:1234
Defensive patterns

Strategy: validation

Validate before calling

String[] parts = col.split(":", 2);
if (parts.length == 2) {
    try { Double.parseDouble(parts[1]); } catch (NumberFormatException e) {
        throw new IllegalArgumentException("Non-numeric count in line " + lineno + ": " + col);
    }
}

Type guard

static boolean isParsableDouble(String s) { try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; } }

Try / catch

try { table.readPhrasesWithTagScores(file); } catch (RuntimeException e) { if (e.getMessage().startsWith("Error processing field")) { LOG.error("Fix data file: {}", e.getMessage()); } throw e; }

Prevention

When it happens

Trigger: A data file line whose column i looks like 'tag:value' (splits into 2 by the count delimiter) but where value is non-numeric, e.g. 'NN:high', 'VB:1,5', or a count with a stray character.

Common situations: Hand-edited or Excel-exported phrase tables with counts using thousand separators, commas, or text placeholders like 'n/a'.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

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

    Timing timer = new Timing();
    timer.doing("Reading phrases: " + filename);
    BufferedReader br = IOUtils.readerFromString(filename);
    String line;
    int lineno = 0;
    while ((line = br.readLine()) != null) {
      String[] columns = fieldDelimiterPattern.split(line);
      String phrase = columns[0];
      // Pick map factory to use depending on number of tags we have
      MapFactory<String,MutableDouble> mapFactory = (columns.length < 20)?
              MapFactory.<String,MutableDouble>arrayMapFactory(): MapFactory.<String,MutableDouble>linkedHashMapFactory();
      Counter<String> counts = new ClassicCounter<>(mapFactory);
      for (int i = 1; i < columns.length; i++) {
        String[] tagCount = countDelimiterPattern.split(columns[i], 2);
        if (tagCount.length == 2) {
          try {
            counts.setCount(tagCount[0], Double.parseDouble(tagCount[1]));
          } catch (NumberFormatException ex) {
            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);

View on GitHub (pinned to 1b7edd19c4)