stanfordnlp/CoreNLP · error · RuntimeException

Unknown LogPriorType:

Error message

Unknown LogPriorType: 

What it means

LogPrior.getType(String) maps a prior name string (case-insensitive) to a LogPriorType enum. The library only supports null, quadratic, huber, quartic, and cosh names (the 'multiple' option is commented out); any other string throws this RuntimeException. It is a configuration-lookup guard so an invalid prior name fails fast instead of silently defaulting.

Solutions

  1. Use one of the supported names: null, quadratic, huber, quartic, or cosh (case-insensitive)
  2. Check the spelling of the prior option in your properties/flags file
  3. If a L1/lasso prior is desired, note it is not selected via getType; use LogPriorType values directly in code
  4. Call LogPrior.logPriorOptions() or inspect the enum to list valid values before configuring

Example fix

// before
LogPrior prior = LogPrior.getType("lasso");
// after
LogPrior prior = LogPrior.getType("quadratic");
Defensive patterns

Strategy: validation

Validate before calling

Set<String> ok = new HashSet<>(Arrays.asList("null","quadratic","huber","quartic","cosh"));
if (priorName == null || !ok.contains(priorName.toLowerCase(Locale.ROOT)))
  throw new IllegalArgumentException("prior must be one of " + ok + ", got: " + priorName);

Try / catch

try {
  LogPrior prior = LogPrior.getType(name);
} catch (RuntimeException e) {
  logger.warn("Bad prior name '" + name + "', falling back to quadratic");
  LogPrior prior = LogPrior.getType("quadratic");
}

Prevention

When it happens

Trigger: Calling LogPrior.getType(name) with a name other than (case-insensitively) "null", "quadratic", "huber", "quartic", or "cosh" — typically from a properties file or CLI option like prior=lasso or prior=multiple.

Common situations: Copying old Stanford NLP configs that used the removed 'multiple' prior; typos such as 'quadraticc', 'l2', 'gaussian' instead of 'quadratic'; passing null/empty name strings from config parsing.

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

Appendix: source

Thrown at src/edu/stanford/nlp/classify/LogPrior.java:28

 *
 * @author Galen Andrew
 */
public class LogPrior implements Serializable {

  private static final long serialVersionUID = 7826853908892790965L;

  public enum LogPriorType { NULL, QUADRATIC, HUBER, QUARTIC, COSH, ADAPT, MULTIPLE_QUADRATIC }

  private static final double LOG2 = Math.log(2);
  
  public static LogPriorType getType(String name) {
    if (name.equalsIgnoreCase("null")) { return LogPriorType.NULL; }
    else if (name.equalsIgnoreCase("quadratic")) { return LogPriorType.QUADRATIC; }
    else if (name.equalsIgnoreCase("huber")) { return LogPriorType.HUBER; }
    else if (name.equalsIgnoreCase("quartic")) { return LogPriorType.QUARTIC; }
    else if (name.equalsIgnoreCase("cosh")) { return LogPriorType.COSH; }
//    else if (name.equalsIgnoreCase("multiple")) { return LogPriorType.MULTIPLE; }
    else { throw new RuntimeException("Unknown LogPriorType: " + name); }
  }

  // these fields are just for the ADAPT prior -
  // is there a better way to do this?
  private double[] means = null;
  private LogPrior otherPrior = null;

  public static LogPrior getAdaptationPrior(double[] means, LogPrior otherPrior) {
    LogPrior lp = new LogPrior(LogPriorType.ADAPT);
    lp.means = means;
    lp.otherPrior = otherPrior;
    return lp;
  }

  public LogPriorType getType() {
    return type;
  }

View on GitHub (pinned to 1b7edd19c4)