{"record":{"id":"69b1ad24b582bfce","repo":"stanfordnlp/CoreNLP","slug":"need-to-do-training-first","errorCode":null,"errorMessage":"need to do training first!","messagePattern":"need to do training first!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/quoteattribution/Sieves/QMSieves/SupervisedSieve.java","lineNumber":31,"sourceCode":"/**\n * Created by mjfang on 7/7/16.\n */\npublic class SupervisedSieve extends QMSieve {\n\n  private ExtractQuotesClassifier quotesClassifier;\n\n  public SupervisedSieve(Annotation doc, Map<String, List<Person>> characterMap,\n                         Map<Integer,String> pronounCorefMap, Set<String> animacyList) {\n    super(doc, characterMap, pronounCorefMap, animacyList, \"supervised\");\n  }\n\n  public void loadModel(String filename) {\n    quotesClassifier = new ExtractQuotesClassifier(filename);\n  }\n\n  public void doQuoteToMention(Annotation doc) {\n    if (quotesClassifier == null) {\n      throw new RuntimeException(\"need to do training first!\");\n    }\n    SupervisedSieveTraining.FeaturesData fd = SupervisedSieveTraining.featurize(new SupervisedSieveTraining.SieveData(doc, this.characterMap, this.pronounCorefMap, this.animacySet), null, false);\n    quotesClassifier.scoreBestMentionNew(fd, doc);\n  }\n\n}\n","sourceCodeStart":13,"sourceCodeEnd":38,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/quoteattribution/Sieves/QMSieves/SupervisedSieve.java#L13-L38","documentation":"SupervisedSieve.doQuoteToMention requires a trained quotesClassifier, which is only set by calling loadModel(filename). If it is null the sieve throws RuntimeException(\"need to do training first!\") at src/edu/stanford/nlp/quoteattribution/Sieves/QMSieves/SupervisedSieve.java:31. This is an initialization-order guard: the supervised quote-to-mention sieve cannot score mentions without its model.","triggerScenarios":"Running the quote attribution pipeline with the supervised sieve enabled but never calling loadModel on the sieve, or loadModel failing silently / not being called before processAnnotation/doQuoteToMention runs.","commonSituations":"Using the quoteattribution annotator without supplying the trained supervised model file; building a custom pipeline that constructs SupervisedSieve directly; config missing the model path property.","solutions":["Call sieve.loadModel(\"path/to/supervised_model\") before invoking doQuoteToMention.","Ensure the quoteattribution pipeline is configured with the supervised model path so it wires the classifier in.","Add a null check that calls loadModel lazily with a default model path.","If no supervised model is available, use a non-supervised sieve configuration instead."],"exampleFix":"// before\nSupervisedSieve sieve = new SupervisedSieve(...);\nsieve.doQuoteToMention(doc); // throws\n// after\nSupervisedSieve sieve = new SupervisedSieve(...);\nsieve.loadModel(\"models/quote_supervised.model\");\nsieve.doQuoteToMention(doc);","handlingStrategy":"validation","validationCode":"if (sieve == null || sieveIsUninitialized) throw new IllegalStateException(\"call loadModel() before doQuoteToMention\");","typeGuard":null,"tryCatchPattern":"try {\n  sieve.doQuoteToMention(doc);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"training first\")) sieve.loadModel(defaultModelPath);\n}","preventionTips":["Call loadModel immediately after constructing the sieve","Use a factory that guarantees the model is loaded","Assert classifier non-null in pipeline setup code"],"tags":["java","initialization","nlp","missing-model"],"backgroundTag":"missing-required-config","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"}