{"record":{"id":"152b6d41df0f5b30","repo":"stanfordnlp/CoreNLP","slug":"invalid-classifier-type-relationextractorclassi","errorCode":null,"errorMessage":"Invalid classifier type: ${relationExtractorClassifierType}","messagePattern":"Invalid classifier type: (.+?)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/machinereading/BasicRelationExtractor.java","lineNumber":122,"sourceCode":"    GeneralDataset<String, String> trainSet = createDataset(sentences);\n    trainMulticlass(trainSet);\n  }\n\n  public void trainMulticlass(GeneralDataset<String, String> trainSet) {\n    if (relationExtractorClassifierType.equalsIgnoreCase(\"linear\")) {\n      LinearClassifierFactory<String, String> lcFactory = new LinearClassifierFactory<>(1e-4, false, sigma);\n      lcFactory.setVerbose(false);\n      // use in-place SGD instead of QN. this is faster but much worse!\n      // lcFactory.useInPlaceStochasticGradientDescent(-1, -1, 1.0);\n      // use a hybrid minimizer: start with in-place SGD, continue with QN\n      // lcFactory.useHybridMinimizerWithInPlaceSGD(50, -1, sigma);\n      classifier = lcFactory.trainClassifier(trainSet);\n    } else if (relationExtractorClassifierType.equalsIgnoreCase(\"svm\")) {\n      SVMLightClassifierFactory<String, String> svmFactory = new SVMLightClassifierFactory<>();\n      svmFactory.setC(sigma);\n      classifier = svmFactory.trainClassifier(trainSet);\n    } else {\n      throw new RuntimeException(\"Invalid classifier type: \" + relationExtractorClassifierType);\n    }\n    if (logger.isLoggable(Level.FINE)) {\n      reportWeights(classifier, null);\n    }\n  }\n\n  protected static void reportWeights(LinearClassifier<String, String> classifier, String classLabel) {\n    if (classLabel != null) logger.fine(\"CLASSIFIER WEIGHTS FOR LABEL \" + classLabel);\n    Map<String, Counter<String>> labelsToFeatureWeights = classifier.weightsAsMapOfCounters();\n    List<String> labels = new ArrayList<>(labelsToFeatureWeights.keySet());\n    Collections.sort(labels);\n    for (String label: labels) {\n      Counter<String> featWeights = labelsToFeatureWeights.get(label);\n      List<Pair<String, Double>> sorted = Counters.toSortedListWithCounts(featWeights);\n      StringBuilder bos = new StringBuilder();\n      bos.append(\"WEIGHTS FOR LABEL \").append(label).append(':');\n      for (Pair<String, Double> feat: sorted) {\n        bos.append(' ').append(feat.first()).append(':').append(feat.second()+\"\\n\");","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/machinereading/BasicRelationExtractor.java#L104-L140","documentation":"In BasicRelationExtractor.trainMulticlass, the configured relationExtractorClassifierType selects a factory for training the relation classifier. Only \"loglinear\" (logistic) and \"svm\" branches exist; any other value (case-insensitive comparison) falls into the final else and throws RuntimeException. It is a configuration error: the chosen classifier family is not implemented/supported by this trainer.","triggerScenarios":"Setting the classifier type property (relationExtractorClassifierType) to anything other than \"loglinear\" or \"svm\" (e.g. \"naivebayes\", \"logistic\", \"SVM \" with trailing whitespace, or a typo) before calling train()/trainMulticlass().","commonSituations":"Typing the classifier name by hand in the training properties file; copying a config from a different NLP pipeline that supports more classifier types; assuming case or synonyms like \"maxent\" are accepted; upgrading CoreNLP and renaming the option.","solutions":["Set the classifier-type property to exactly \"loglinear\" (logistic regression) or \"svm\" (SVMLight).","Check for typos, extra whitespace, or wrong case-sensitivity assumptions in the config value.","Read BasicRelationExtractor.java to confirm which types your version supports, and add a new factory branch if you need another learner.","Log/echo the property value at startup so a misconfigured value surfaces before training starts."],"exampleFix":"// before (properties)\nrelation.extractor.classifierType = maxent\n// after\nrelation.extractor.classifierType = loglinear","handlingStrategy":"validation","validationCode":"String type = props.getProperty(\"relation.extractor.classifierType\");\nif (!\"loglinear\".equalsIgnoreCase(type) && !\"svm\".equalsIgnoreCase(type)) {\n  throw new IllegalArgumentException(\"classifierType must be 'loglinear' or 'svm', got: \" + type);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Whitelist the classifier type in a central config-validation step at startup.","Compare with equalsIgnoreCase but still normalize/trim the value.","Document the two supported values next to the property key."],"tags":["java","configuration","machine-learning"],"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"}