{"record":{"id":"d18e7f0635e5f583","repo":"stanfordnlp/CoreNLP","slug":"not-implemented-for-this-class","errorCode":null,"errorMessage":"Not implemented for this class.","messagePattern":"Not implemented for this class\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java","lineNumber":1046,"sourceCode":"  }\n\n  public void classifyStdin() throws IOException {\n    classifyStdin(plainTextReaderAndWriter());\n  }\n\n  public void classifyStdin(DocumentReaderAndWriter<IN> readerWriter) throws IOException {\n    BufferedReader is = IOUtils.readerFromStdin(flags.inputEncoding);\n    for (String line; (line = is.readLine()) != null; ) {\n      Collection<List<IN>> documents = makeObjectBankFromString(line, readerWriter);\n      if (flags.keepEmptySentences && documents.isEmpty()) {\n        documents = Collections.<List<IN>>singletonList(Collections.<IN>emptyList());\n      }\n      classifyAndWriteAnswers(documents, readerWriter, false);\n    }\n  }\n\n  public Triple<Counter<Integer>, Counter<Integer>, TwoDimensionalCounter<Integer,String>> printProbsDocument(List<IN> document) {\n    throw new UnsupportedOperationException(\"Not implemented for this class.\");\n  }\n\n  /** Does nothing by default.  Subclasses can override if necessary. */\n  public void dumpFeatures(Collection<List<IN>> documents) {}\n\n  /**\n   * Load a text file, run the classifier on it, and then print the answers to\n   * stdout (with timing to stderr). This uses the value of flags.plainTextDocumentReaderAndWriter\n   * to determine how to read the textFile format. By default this gives\n   * edu.stanford.nlp.sequences.PlainTextDocumentReaderAndWriter.\n   * <i>Note:</i> This means that it works right for\n   * a plain textFile (and not a tab-separated columns test file).\n   *\n   * @param textFile The file to test on.\n   */\n  public void classifyAndWriteAnswers(String textFile)\n          throws IOException {\n    classifyAndWriteAnswers(textFile, plainTextReaderAndWriter(), false);","sourceCodeStart":1028,"sourceCodeEnd":1064,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java#L1028-L1064","documentation":"AbstractSequenceClassifier.printProbsDocument is a stub: the base class does not provide per-document probability output, so calling it always throws UnsupportedOperationException. Only subclasses that override it support this operation.","triggerScenarios":"Calling classifier.printProbsDocument(document) on a classifier instance whose class (e.g. a generic ColumnDocumentClassifierAndWriter-less subclass) does not override printProbsDocument.","commonSituations":"Calling the method on a classifier loaded from a serialized model whose runtime class lacks the override; expecting base-class functionality that is documented as subclass-provided.","solutions":["Check the concrete class (classifier.getClass()) and whether it overrides printProbsDocument","Use an alternative API such as classify with a ProbabilityDocumentReaderAndWriter or the classification() method to get scores","Override printProbsDocument in your subclass","Upgrade the library version if a newer one implements it"],"exampleFix":"// before\nTriple<Counter<Integer>, Counter<Integer>, TwoDimensionalCounter<Integer,String>> p = classifier.printProbsDocument(doc);\n// after\nif (classifier.getClass().equals(AbstractSequenceClassifier.class)) {\n  // use classify(doc) and inspect labels/scores instead\n} else {\n  var p = classifier.printProbsDocument(doc);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"boolean supported = !(classifier.getClass() == AbstractSequenceClassifier.class);\n// only call printProbsDocument when a subclass overrides it","tryCatchPattern":"try { probs = classifier.printProbsDocument(doc); }\ncatch (UnsupportedOperationException e) { probs = fallbackScoring(doc); }","preventionTips":["Check for an override in the concrete class before calling stub methods","Prefer documented alternatives (classification(), classify()) for scores","Read the Javadoc: base-class stubs mean subclass support only"],"tags":["unsupported-operation","subclass","api"],"backgroundTag":"method-not-implemented","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"}