{"record":{"id":"7df75fb0f2a17f42","repo":"stanfordnlp/CoreNLP","slug":"unknown-prior-type-7df75f","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/CRFNonLinearLogConditionalObjectiveFunction.java","lineNumber":95,"sourceCode":"  {\n    if (priorTypeStr == null) return QUADRATIC_PRIOR;  // default\n    if (\"QUADRATIC\".equalsIgnoreCase(priorTypeStr)) {\n      return QUADRATIC_PRIOR;\n    } else if (\"L1\".equalsIgnoreCase(priorTypeStr)) {\n      return L1_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(\"lasso\") ||\n               priorTypeStr.equalsIgnoreCase(\"ridge\") ||\n               priorTypeStr.equalsIgnoreCase(\"ae-lasso\") ||\n               priorTypeStr.equalsIgnoreCase(\"g-lasso\") ||\n               priorTypeStr.equalsIgnoreCase(\"sg-lasso\") ||\n               priorTypeStr.equalsIgnoreCase(\"NONE\") ) {\n      return NO_PRIOR;\n    } else {\n      throw new IllegalArgumentException(\"Unknown prior type: \" + priorTypeStr);\n    }\n  }\n\n  CRFNonLinearLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, SeqClassifierFlags flags, int numNodeFeatures, int numEdgeFeatures, double[][][][] featureVal) {\n    this.window = window;\n    this.classIndex = classIndex;\n    this.numClasses = classIndex.size();\n    this.labelIndices = labelIndices;\n    this.data = data;\n    this.featureVal = featureVal;\n    this.flags = flags;\n    this.map = map;\n    this.labels = labels;\n    this.prior = getPriorType(flags.priorType);\n    this.backgroundSymbol = flags.backgroundSymbol;\n    this.sigma = flags.sigma;\n    this.outputLayerSize = numClasses;\n    this.numHiddenUnits = flags.numHiddenUnits;","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFNonLinearLogConditionalObjectiveFunction.java#L77-L113","documentation":"CRFNonLinearLogConditionalObjectiveFunction.getPriorType converts a prior-name string (from flags.priorType) into the internal integer constant. If the string matches none of the recognized names (L1/L2, lasso, ridge, ae-lasso, g-lasso, sg-lasso, NONE, etc.), it throws an IllegalArgumentException naming the unrecognized value. It fails fast so an unsupported regularizer is never silently ignored.","triggerScenarios":"Constructing the non-linear CRF objective (directly or via SeqClassifierFlags.priorType) with a priorTypeStr that is misspelled, wrong-cased beyond equalsIgnoreCase support, or entirely unsupported (e.g. \"elastic-net\" or a typo like \"l2regularization\").","commonSituations":"Hand-editing a training properties file and typo-ing the prior name; copying a prior value from another library (e.g. sklearn \"l1\") that Stanford NLP does not recognize; upgrading/downgrading versions where a prior name was removed.","solutions":["Set flags.priorType to one of the supported strings exactly as listed in the source (e.g. \"L2\", \"L1\", \"lasso\", \"ridge\", \"ae-lasso\", \"g-lasso\", \"sg-lasso\", \"NONE\").","Check for typos or stray whitespace in the properties file value (e.g. \"l2 \" with a trailing space).","Consult SeqClassifierFlags javadoc for the exact prior names supported by your library version.","If a prior you need is unsupported, implement a custom prior or fall back to L2 regularization."],"exampleFix":"// before\nproperties.setProperty(\"priorType\", \"elastic-net\");\n// after\nproperties.setProperty(\"priorType\", \"L2\");","handlingStrategy":"validation","validationCode":"java.util.Set<String> ok = new java.util.HashSet<>(java.util.Arrays.asList(\"l1\",\"l2\",\"gaussianPrior\",\"laplacianPrior\",\"quadraticPrior\",\"lasso\",\"ridge\",\"ae-lasso\",\"g-lasso\",\"sg-lasso\",\"none\"));\nif (!ok.contains(flags.priorType.toLowerCase().trim())) throw new IllegalArgumentException(\"unknown priorType: \" + flags.priorType);","typeGuard":"static boolean isValidPriorType(String s) { return s != null && java.util.Arrays.stream(new String[]{\"l1\",\"l2\",\"gaussianprior\",\"laplacianprior\",\"quadraticprior\",\"lasso\",\"ridge\",\"ae-lasso\",\"g-lasso\",\"sg-lasso\",\"none\"}).anyMatch(s.trim().toLowerCase()::equals); }","tryCatchPattern":"try {\n  CRFNonLinearLogConditionalObjectiveFunction f = new CRFNonLinearLogConditionalObjectiveFunction(data, labels, window, classIndex, labelIndices, map, flags);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown prior type\")) {\n    log.error(\"Fix flags.priorType; got: \" + e.getMessage());\n    flags.priorType = \"L2\";\n  } else throw e;\n}","preventionTips":["Copy prior names exactly from the SeqClassifierFlags documentation for your version.","Trim and normalize prior strings read from properties files.","Add a startup validation of all flag values before constructing the objective.","Watch for prior-name changes when upgrading Stanford NLP versions."],"tags":["crf","prior","invalid-argument","config"],"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-15T23:17:13.987Z"}