stanfordnlp/CoreNLP · warning
Error extracting annotation from
Error message
Error extracting annotation from ${te} What it means
CoreMapExpressionExtractor.annotateExpressions runs TokensRegex extraction over expressions. When an expression fails to extract (a rule match produced nothing usable, or an exception was thrown), the expression is discarded and a warning naming the offending CoreMap is logged. Extraction continues with remaining expressions.
Solutions
- Enable verbose mode to also see the underlying exception for failed expressions.
- Inspect the failing expression (te) and the rule that processed it; validate the pattern against the actual CoreMap annotations.
- Fix or guard the rule (e.g. check required annotations exist) so extraction succeeds or skips intentionally.
- Test rules incrementally with TokensRegex debugging tools.
Example fix
// before
props.setProperty("verbose", "false"); // root exception hidden
// after
props.setProperty("verbose", "true"); // logs the ex for the failing expression Defensive patterns
Strategy: try-catch
Validate before calling
// verify required annotations exist before extraction
for (CoreMap te : expressions) {
if (te.get(CoreAnnotations.TokensAnnotation.class) == null) {
throw new IllegalStateException("expression missing tokens: " + te);
}
} Try / catch
try {
extractor.extractExpressions(doc);
} catch (Exception ex) {
log.warn("expression extraction failed for document", ex);
// continue with un-enriched annotations
} Prevention
- Run extraction with verbose=true during development.
- Unit-test TokensRegex rules against representative CoreMaps.
- Keep rule files syntax-validated in CI.
When it happens
Trigger: applyCompositeRule/extractExpressions encountering an expression where a rule match fails or a sub-expression throws; exceptions are logged (with the same message) only when verbose=true.
Common situations: Custom TokensRegex rules with patterns that don't match the actual annotation structure; rules referencing missing annotation keys; malformed rule files producing null results.
Related errors
- Parsing failed. Error:
- Bad data format:
- Bad number put into wordToNumber. Word is: \"" + input +…
- Error in wordToNumber function.
- Bad number put into wordToNumber. Word is: \"" + curPart +…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/1aa19371baf05044.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ling/tokensregex/CoreMapExpressionExtractor.java:528
private void annotateExpressions(CoreMap annotation, List<T> expressions) {
// TODO: Logging can be excessive
List<T> toDiscard = new ArrayList<>();
for (T te : expressions) {
// Add attributes and all
if (te.annotation == null) {
try {
boolean extractOkay = te.extractAnnotation(env, annotation);
if (verbose && extractOkay) {
log.info("annotateExpressions() matched " + te + " from " + annotation);
}
if (!extractOkay) {
// Things didn't turn out so well
toDiscard.add(te);
log.warn("Error extracting annotation from " + te /*+ ", " + te.getExtractErrorMessage() */);
}
} catch (Exception ex) {
if (verbose) {
log.warn("Error extracting annotation from " + te);
log.warn(ex);
}
}
}
}
expressions.removeAll(toDiscard);
}
private void annotateExpressions(List<? extends CoreMap> chunks, List<T> expressions) {
// TODO: Logging can be excessive
List<T> toDiscard = new ArrayList<>();
for (T te : expressions) {
// Add attributes and all
try {
boolean extractOkay = te.extractAnnotation(env, chunks);
if (verbose && extractOkay) {
log.info("annotateExpressions() matched " + te + " from " + chunks);
}View on GitHub (pinned to 1b7edd19c4)