stanfordnlp/CoreNLP · error · IllegalArgumentException

Coreference is not implemented for Arabic

Error message

Coreference is not implemented for Arabic

What it means

ArabicDocument.coref() throws IllegalArgumentException because coreference resolution is not implemented for Arabic in the stanford.nlp.simple API. The public coref(Properties) override is a stub that always fails for Arabic documents.

Solutions

  1. Skip coref for ArabicDocument instances (instanceof check before calling).
  2. Run coreference only on supported-language documents (e.g. English).
  3. Use an external Arabic coreference system instead of the CoreNLP simple API.

Example fix

// before
Map<Integer, CorefChain> chains = doc.coref();
// after
if (!(doc instanceof ArabicDocument)) {
  Map<Integer, CorefChain> chains = doc.coref();
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (doc instanceof edu.stanford.nlp.simple.ArabicDocument) skipCoref = true;

Type guard

boolean supportsCoref(Document doc) { return !(doc instanceof edu.stanford.nlp.simple.ArabicDocument); }

Try / catch

try {
  doc.coref();
} catch (IllegalArgumentException e) {
  if (e.getMessage() != null && e.getMessage().contains("not implemented")) {
    log.warn("Coreference unavailable for this language, skipping");
  } else throw e;
}

Prevention

When it happens

Trigger: Calling coref() on an ArabicDocument, or running a Document operation chain that requires coreference on Arabic text.

Common situations: Multilingual pipelines running the full Stanford CoreNLP annotator set (including dcoref/coref) uniformly over documents of all languages.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/simple/ArabicDocument.java:100

  protected Document runSentiment(Properties props) {
    throw new IllegalArgumentException("Sentiment analysis is not implemented for Arabic");
  }


  @Override
  protected Document runDepparse(Properties props) {
    throw new IllegalArgumentException("Dependency parsing is not implemented for Arabic");
  }

  @Override
  protected Document runNER(Properties props) {
    throw new IllegalArgumentException("NER is not implemented for Arabic");
  }


  @Override
  public Map<Integer, CorefChain> coref(Properties props) {
    throw new IllegalArgumentException("Coreference is not implemented for Arabic");
  }

}

View on GitHub (pinned to 1b7edd19c4)