{"record":{"id":"8c4bae6c44a2cebe","repo":"stanfordnlp/CoreNLP","slug":"unknown-prior-type-8c4bae","errorCode":null,"errorMessage":"Unknown prior type: ","messagePattern":"Unknown prior type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFNonLinearSecondOrderLogConditionalObjectiveFunction.java","lineNumber":85,"sourceCode":"\n  String crfType = \"maxent\";\n  String backgroundSymbol;\n\n  public static boolean VERBOSE = false;\n\n  public static int getPriorType(String priorTypeStr)\n  {\n    if (priorTypeStr == null) return QUADRATIC_PRIOR;  // default\n    if (\"QUADRATIC\".equalsIgnoreCase(priorTypeStr)) {\n      return QUADRATIC_PRIOR;\n    } else if (\"HUBER\".equalsIgnoreCase(priorTypeStr)) {\n      return HUBER_PRIOR;\n    } else if (\"QUARTIC\".equalsIgnoreCase(priorTypeStr)) {\n      return QUARTIC_PRIOR;\n    } else if (priorTypeStr.equalsIgnoreCase(\"NONE\")) {\n      return NO_PRIOR;\n    } else {\n      throw new IllegalArgumentException(\"Unknown prior type: \" + priorTypeStr);\n    }\n  }\n\n  CRFNonLinearSecondOrderLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures) {\n    this(data, labels, window, classIndex, labelIndices, map, QUADRATIC_PRIOR, flags, numNodeFeatures, numEdgeFeatures);\n  }\n\n  CRFNonLinearSecondOrderLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, int prior, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures) {\n    this.window = window;\n    this.classIndex = classIndex;\n    this.numClasses = classIndex.size();\n    this.labelIndices = labelIndices;\n    this.data = data;\n    this.flags = flags;\n    this.map = map;\n    this.labels = labels;\n    this.prior = prior;\n    this.backgroundSymbol = flags.backgroundSymbol;","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFNonLinearSecondOrderLogConditionalObjectiveFunction.java#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set flags.priorType to one of the accepted values: \"L1\", \"L2\"/\"QUADRATIC\", \"HUBER\", \"QUARTIC\", or \"NONE\".","Check spelling and remove spaces/extra tokens from the priorType property.","If a custom prior is needed, extend getPriorType rather than passing an unrecognized string.","Consult the SeqClassifierFlags javadoc for the exact supported prior names in your CoreNLP version."],"exampleFix":"// before\nprops.setProperty(\"priorType\", \"elasticNet\");\n// after\nprops.setProperty(\"priorType\", \"L2\");","handlingStrategy":"validation","validationCode":"// validate priorType before training\njava.util.Set<String> allowed = new java.util.HashSet<>(\n    java.util.Arrays.asList(\"L1\", \"L2\", \"QUADRATIC\", \"HUBER\", \"QUARTIC\", \"NONE\"));\nif (!allowed.contains(props.getProperty(\"priorType\", \"QUADRATIC\").toUpperCase()))\n  throw new IllegalArgumentException(\"unsupported priorType: \" + props.getProperty(\"priorType\"));","typeGuard":null,"tryCatchPattern":"try {\n  classifier.train(props);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown prior type\")) {\n    props.setProperty(\"priorType\", \"L2\"); // safe default\n    classifier.train(props);\n  } else throw e;\n}","preventionTips":["Keep a whitelist of valid priorType strings in your training config loader","Copy property files only between matching Stanford tool versions","Validate the whole properties file before launching long training runs"],"tags":["crf","prior","enum","configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}