stanfordnlp/CoreNLP · error · RuntimeException

Method not implemented!

Error message

Method not implemented!

What it means

DcorefPronounResolver.resolvePronouns(SemanticGraph) is an unimplemented overload: it unconditionally throws RuntimeException("Method not implemented!") at src/edu/stanford/nlp/scenegraph/DcorefPronounResolver.java:40. Only the List<CoreLabel> token-based overload is implemented, so callers must not pass a SemanticGraph to this resolver.

Solutions

  1. Convert the SemanticGraph to a List<CoreLabel> (e.g. sg.vertexListSorted()) and call the token-list overload.
  2. Use a different PronounResolver implementation that supports SemanticGraph input.
  3. Add the conversion inside a wrapper method so the unimplemented overload is never invoked.

Example fix

// before
resolver.resolvePronouns(sg); // throws
// after
List<CoreLabel> tokens = sg.vertexListSorted();
resolver.resolvePronouns(tokens);
Defensive patterns

Strategy: type-guard

Validate before calling

if (input instanceof SemanticGraph) {
  input = ((SemanticGraph) input).vertexListSorted(); // convert to List<CoreLabel>
}

Type guard

List<CoreLabel> toTokens(Object graphOrTokens) {
  if (graphOrTokens instanceof SemanticGraph) return ((SemanticGraph) graphOrTokens).vertexListSorted();
  return (List<CoreLabel>) graphOrTokens;
}

Try / catch

try {
  return resolver.resolvePronouns(input);
} catch (RuntimeException e) {
  if (e.getMessage().contains("not implemented")) return resolver.resolvePronouns(toTokens(input));
  throw e;
}

Prevention

When it happens

Trigger: Invoking resolvePronouns on a DcorefPronounResolver instance with a SemanticGraph argument — e.g. calling the base-class API with a parsed graph instead of a token list, or framework code dispatching to the SemanticGraph overload.

Common situations: Writing scene-graph code that calls the generic PronounResolver interface with a SemanticGraph; copying example code that used the token-list overload but passing a graph from the dependency parser.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/77060a2ae8a4ddb2. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/scenegraph/DcorefPronounResolver.java:40

 * coreference resolution system.
 *
 * @author Sebastian Schuster
 */

public class DcorefPronounResolver extends AbstractPronounResolver {

  private StanfordCoreNLP pipeline;

  public DcorefPronounResolver() {
    Properties props  = new Properties();
    props.setProperty("annotators", "parse,ner,lemma,dcoref");
    props.setProperty("enforceRequirements", "false");
    pipeline = new StanfordCoreNLP(props);
  }

  @Override
  protected HashMap<Integer, Integer> resolvePronouns(SemanticGraph sg) {
    throw new RuntimeException("Method not implemented!");
  }


  @Override
  protected HashMap<Integer, Integer> resolvePronouns(List<CoreLabel> tokens) {

    HashMap<Integer, Integer> pronPairs = new HashMap<Integer,Integer>(1);

    CoreMap sentence = new CoreLabel();
    sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);
    sentence.set(CoreAnnotations.SentenceIndexAnnotation.class, 1);

    List<CoreMap> sentences = new ArrayList<CoreMap>(1);
    sentences.add(sentence);

    Annotation annotation = new Annotation(sentences);

    pipeline.annotate(annotation);

View on GitHub (pinned to 1b7edd19c4)