stanfordnlp/CoreNLP · error · IllegalArgumentException

Unknown format

Error message

Unknown format ${format}

What it means

TaggedFileRecord.reader() switches on the configured Format enum (TEXT, TREES, TSV) to create the matching file reader. If the stored format value isn't one of the known enum cases, the default branch throws IllegalArgumentException. This normally can't happen via Format.valueOf, but can arise from a manually constructed record or an enum added without updating reader().

Solutions

  1. Set the format to one of the supported values: format=TEXT, format=TREES, or format=TSV in the file description string.
  2. Upgrade or align your Stanford POS tagger library version so enum constants and reader() agree.
  3. If constructing TaggedFileRecord programmatically, pass a valid Format enum constant.

Example fix

// before
TaggedFileRecord.record("data/test.txt").setFormat("XML").build();
// after
TaggedFileRecord.record("data/test.txt").setFormat("TEXT").build();
Defensive patterns

Strategy: validation

Validate before calling

// Java
Set<String> allowed = Set.of("TEXT", "TREES", "TSV");
boolean ok = allowed.contains(formatString.toUpperCase(Locale.ROOT));

Try / catch

// Java
try {
  reader = record.reader();
} catch (IllegalArgumentException e) {
  throw new ConfigException("Unsupported format: use TEXT, TREES, or TSV", e);
}

Prevention

When it happens

Trigger: Constructing a TaggedFileRecord with a Format value not handled by reader()'s switch (e.g., a newer enum constant used with an older switch, or a null/unmapped format passed programmatically), typically reached via runTagger, countSentences, or TaggedFileRecord.createRecords.

Common situations: Version mismatch between the tagger jar and code referencing a newer Format constant; programmatic construction of TaggedFileRecord with an invalid format; typos in a custom config path that bypasses valueOf validation.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/tagger/io/TaggedFileRecord.java:130

    }
    if (skipMWT) {
      s.append("," + SKIP_MWT + "=true");
    }
    return s.toString();
  }

  public String filename() { return file; }

  public TaggedFileReader reader() {
    switch(format) {
    case TEXT:
      return new TextTaggedFileReader(this);
    case TREES:
      return new TreeTaggedFileReader(this);
    case TSV:
      return new TSVTaggedFileReader(this);
    default:
      throw new IllegalArgumentException("Unknown format " + format);
    }
  }

  public static List<TaggedFileRecord> createRecords(Properties config,
                                                     String description) {
    String[] pieces = description.split(";");
    List<TaggedFileRecord> records = new ArrayList<>();
    for (String piece : pieces) {
      records.add(createRecord(config, piece));
    }
    return records;
  }

  public static TaggedFileRecord createRecord(Properties config,
                                              String description) {
    String[] pieces = description.split(",");
    if (pieces.length == 1) {
      return new TaggedFileRecord(description, Format.TEXT,

View on GitHub (pinned to 1b7edd19c4)