stanfordnlp/CoreNLP · error · IllegalArgumentException

Unknown prior type:

Error message

Unknown prior type: 

What it means

getPriorType maps a prior name string (L1, L2, QUADRATIC, HUBER, QUARTIC, NONE, ...) to an internal prior constant; unknown strings throw IllegalArgumentException. It validates the flags.priorType value when constructing a CRFNonLinearSecondOrderLogConditionalObjectiveFunction.

Solutions

  1. Set flags.priorType to one of the accepted values: "L1", "L2"/"QUADRATIC", "HUBER", "QUARTIC", or "NONE".
  2. Check spelling and remove spaces/extra tokens from the priorType property.
  3. If a custom prior is needed, extend getPriorType rather than passing an unrecognized string.
  4. Consult the SeqClassifierFlags javadoc for the exact supported prior names in your CoreNLP version.

Example fix

// before
props.setProperty("priorType", "elasticNet");
// after
props.setProperty("priorType", "L2");
Defensive patterns

Strategy: validation

Validate before calling

// validate priorType before training
java.util.Set<String> allowed = new java.util.HashSet<>(
    java.util.Arrays.asList("L1", "L2", "QUADRATIC", "HUBER", "QUARTIC", "NONE"));
if (!allowed.contains(props.getProperty("priorType", "QUADRATIC").toUpperCase()))
  throw new IllegalArgumentException("unsupported priorType: " + props.getProperty("priorType"));

Try / catch

try {
  classifier.train(props);
} catch (IllegalArgumentException e) {
  if (e.getMessage().startsWith("Unknown prior type")) {
    props.setProperty("priorType", "L2"); // safe default
    classifier.train(props);
  } else throw e;
}

Prevention

When it happens

Trigger: Setting SeqClassifierFlags.priorType (e.g. via properties in CRFClassifier training) to a string not in the accepted set -- including typos like "quadraticprior", "elasticnet", or case/format variants not handled by equalsIgnoreCase.

Common situations: Copying training property files between Stanford tools where prior name vocabularies differ; hand-edited trainer configs; passing a prior class name instead of the short string token.

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/8c4bae6c44a2cebe. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ie/crf/CRFNonLinearSecondOrderLogConditionalObjectiveFunction.java:85

  String crfType = "maxent";
  String backgroundSymbol;

  public static boolean VERBOSE = false;

  public static int getPriorType(String priorTypeStr)
  {
    if (priorTypeStr == null) return QUADRATIC_PRIOR;  // default
    if ("QUADRATIC".equalsIgnoreCase(priorTypeStr)) {
      return QUADRATIC_PRIOR;
    } else if ("HUBER".equalsIgnoreCase(priorTypeStr)) {
      return HUBER_PRIOR;
    } else if ("QUARTIC".equalsIgnoreCase(priorTypeStr)) {
      return QUARTIC_PRIOR;
    } else if (priorTypeStr.equalsIgnoreCase("NONE")) {
      return NO_PRIOR;
    } else {
      throw new IllegalArgumentException("Unknown prior type: " + priorTypeStr);
    }
  }

  CRFNonLinearSecondOrderLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures) {
    this(data, labels, window, classIndex, labelIndices, map, QUADRATIC_PRIOR, flags, numNodeFeatures, numEdgeFeatures);
  }

  CRFNonLinearSecondOrderLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, int prior, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures) {
    this.window = window;
    this.classIndex = classIndex;
    this.numClasses = classIndex.size();
    this.labelIndices = labelIndices;
    this.data = data;
    this.flags = flags;
    this.map = map;
    this.labels = labels;
    this.prior = prior;
    this.backgroundSymbol = flags.backgroundSymbol;

View on GitHub (pinned to 1b7edd19c4)