stanfordnlp/CoreNLP · error · IllegalArgumentException

Unrecognized format specification in

Error message

Unrecognized format specification in ${format}

What it means

formatCsv parses the -csvFormat string character by character; after '$' only digits, 'c' (class/gold answer), or 'n' (newline) are valid. Any other character following '$' throws IllegalArgumentException naming the full format string, protecting users from silently malformed output templates.

Solutions

  1. Replace the invalid specifier with a digit index, '$c' (gold answer class), or '$n' (newline)
  2. Use a literal tab character (or real \t in the property) instead of '$t'
  3. Print the format string from properties to spot invisible/typo characters

Example fix

// before
props.setProperty("csvFormat", "$0\t$t\n");
// after
props.setProperty("csvFormat", "$0\t$1\t$c$n");
Defensive patterns

Strategy: validation

Validate before calling

if (!csvFormat.matches("(\$[0-9cn]|[^$])*(\$[0-9cn]|[^$])*")) { /* validate: every $ is followed by digit, c, or n */ for (int i=0;i<csvFormat.length()-1;i++) if (csvFormat.charAt(i)=='$' && !"cn".contains(String.valueOf(csvFormat.charAt(i+1))) && !Character.isDigit(csvFormat.charAt(i+1))) throw new IllegalStateException("Bad specifier at " + i); }

Type guard

null

Try / catch

try { testExamples(...); } catch (IllegalArgumentException e) { log.error("Invalid csvFormat string: " + e.getMessage()); }

Prevention

When it happens

Trigger: A csvFormat containing an unsupported escape after '$', e.g. "$x", "$t", "$ " — passed via testExamples/testExample properties.

Common situations: Typo in format string; assuming tab can be written as '$t' instead of a literal tab or '\t'; copying formats between tools with different specifiers.

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/3dbdd3d2e700497a. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/classify/ColumnDataClassifier.java:816

        if (ch2 >= '0' && ch2 <= '9') {
          int field = ch2 - '0';
          if (field < fields.length) {
            out.append(fields[field]);
          } else {
            throw new IllegalArgumentException("Not enough columns for format " + format);
          }
        } else if (ch2 == 'c') {
          if (answer != null) {
            out.append(answer);
          } else if (globalFlags.goldAnswerColumn < fields.length) {
            out.append(fields[globalFlags.goldAnswerColumn]);
          } else {
            out.append("Class");
          }
        } else if (ch2 == 'n') {
          out.append('\n');
        } else {
          throw new IllegalArgumentException("Unrecognized format specification in " + format);
        }
        i++; // have also dealt with next character giving format
      } else {
        out.append(ch);
      }
    }
    return out.toString();
  }


  /**
   * Extracts all the features from a certain input datum.
   *
   * @param strs The data String[] to extract features from
   * @return The constructed Datum
   */
  private Datum<String,String> makeDatum(String[] strs) {
    String goldAnswer = globalFlags.goldAnswerColumn < strs.length ? strs[globalFlags.goldAnswerColumn]: "";

View on GitHub (pinned to 1b7edd19c4)