{"record":{"id":"4c78a1cf8d5774dd","repo":"stanfordnlp/CoreNLP","slug":"unknown-prior-type","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/CRFLogConditionalObjectiveFunction.java","lineNumber":119,"sourceCode":"    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 (\"DROPOUT\".equalsIgnoreCase(priorTypeStr)) {\n      return DROPOUT_PRIOR;\n    } else if (\"NONE\".equalsIgnoreCase(priorTypeStr)) {\n      return NO_PRIOR;\n    } else if (priorTypeStr.equalsIgnoreCase(\"lasso\") ||\n               priorTypeStr.equalsIgnoreCase(\"ridge\") ||\n               priorTypeStr.equalsIgnoreCase(\"gaussian\") ||\n               priorTypeStr.equalsIgnoreCase(\"ae-lasso\") ||\n               priorTypeStr.equalsIgnoreCase(\"sg-lasso\") ||\n               priorTypeStr.equalsIgnoreCase(\"g-lasso\") ) {\n      return NO_PRIOR;\n    } else {\n      throw new IllegalArgumentException(\"Unknown prior type: \" + priorTypeStr);\n    }\n  }\n\n  CRFLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, String priorType, String backgroundSymbol, double sigma, double[][][][] featureVal, int multiThreadGrad) {\n    this(data, labels, window, classIndex, labelIndices, map, priorType, backgroundSymbol, sigma, featureVal, multiThreadGrad, true);\n  }\n\n  CRFLogConditionalObjectiveFunction(int[][][][] data, int[][] labels, int window, Index<String> classIndex, List<Index<CRFLabel>> labelIndices, int[] map, String priorType, String backgroundSymbol, double sigma, double[][][][] featureVal, int multiThreadGrad, boolean calcEmpirical) {\n    this.window = window;\n    this.classIndex = classIndex;\n    this.numClasses = classIndex.size();\n    this.labelIndices = labelIndices;\n    this.map = map;\n    this.data = data;\n    this.featureVal = featureVal;\n    this.labels = labels;\n    this.prior = getPriorType(priorType);\n    this.backgroundSymbol = backgroundSymbol;","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFLogConditionalObjectiveFunction.java#L101-L137","documentation":"getPriorType maps a string prior name (e.g. 'l2'/'gaussian', 'ae-lasso', 'sg-lasso', 'g-lasso', etc.) to the library's numeric prior constants. An unrecognized string is rejected with this IllegalArgumentException at objective-function construction time.","triggerScenarios":"Constructing CRFLogConditionalObjectiveFunction (or training a CRFClassifier) with a prior/regularization string that is not one of the recognized names — typos like 'L1 ' with whitespace, 'huber' misspelled, or a prior type not supported by this CRF variant.","commonSituations":"Training-property typo (priorType=lasso instead of the supported name), case/whitespace issues (though equalsIgnoreCase is used, stray spaces fail), copying prior names from non-CRF estimators that support a different set.","solutions":["Use a supported prior name exactly, e.g. priorType=L2 (or gaussian / ae-lasso / sg-lasso / g-lasso as listed in getPriorType).","Trim whitespace from the property value: priorType=L2 (no trailing spaces).","Check the source of getPriorType in your library version for the exact accepted strings.","If the intended prior is not supported, implement a custom objective function or use the closest supported prior."],"exampleFix":"// before (train.prop)\npriorType=L1\n// after\npriorType=L2\n// (or another name accepted by getPriorType, e.g. gaussian)","handlingStrategy":"validation","validationCode":"static final Set<String> ALLOWED = Set.of(\"l2\",\"l1\",\"gaussian\",\"ae-lasso\",\"sg-lasso\",\"g-lasso\");\nString p = flags.priorType == null ? \"\" : flags.priorType.trim();\nif (!ALLOWED.contains(p.toLowerCase(Locale.ROOT)))\n  throw new IllegalArgumentException(\"Unknown prior type: \" + flags.priorType);","typeGuard":"static boolean isValidPrior(String s) {\n  return s != null && (s.equalsIgnoreCase(\"l2\") || s.equalsIgnoreCase(\"l1\") ||\n    s.equalsIgnoreCase(\"gaussian\") || s.equalsIgnoreCase(\"ae-lasso\") ||\n    s.equalsIgnoreCase(\"sg-lasso\") || s.equalsIgnoreCase(\"g-lasso\"));\n}","tryCatchPattern":"try {\n  func = new CRFLogConditionalObjectiveFunction(data, labels, window, classIndex, labelIndices, map, priorType, backgroundSymbol, sigma, featureVal, threads);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown prior type\")) {\n    log.warn(\"Falling back to L2 prior (was: {})\", priorType);\n    func = new CRFLogConditionalObjectiveFunction(data, labels, window, classIndex, labelIndices, map, \"L2\", backgroundSymbol, sigma, featureVal, threads);\n  } else throw e;\n}","preventionTips":["Trim and normalize prior type strings loaded from properties files.","Keep a whitelist constant of accepted prior names in your config code.","Validate all training properties at startup, before training begins."],"tags":["invalid-argument","configuration","regularization","training","crf"],"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"}