stanfordnlp/CoreNLP · warning
\n \n Current stack
Error message
${warning}\n ${fullExpression(startToken)}\n Current stack: ${trace} What it means
SemgrexParser.jj (JavaCC-generated parser) has a helper that logs a warning containing the offending semgrex expression (fullExpression(startToken)) and the current parser stack trace. When semantic warnings occur during pattern parsing, this builds "<warning>\n <expr>\n Current stack: <trace>" and logs it — the pattern may still parse or may be subtly wrong.
Solutions
- Read the logged warning text and the echoed expression to see which part of the pattern is flagged
- Update the pattern to current semgrex syntax (check SemgrexPattern documentation for the relation you used)
- Test the pattern with a small SemanticGraph to confirm intended matches after fixing
- Keep patterns under version control and re-validate them when upgrading the Stanford CoreNLP version
Example fix
// before
SemgrexPattern p = SemgrexPattern.compile("{} >nsubj {}<<deprecated-syntax");
// after
SemgrexPattern p = SemgrexPattern.compile("{}=src >nsubj {}"); // current syntax Defensive patterns
Strategy: validation
Validate before calling
// Java: pre-check pattern for balanced delimiters before compiling
static boolean balanced(String p) {
int d = 0;
for (char c : p.toCharArray()) {
if (c == '[' || c == '{' || c == '(') d++;
if (c == ']' || c == '}' || c == ')') d--;
if (d < 0) return false;
}
return d == 0;
} Try / catch
// Compile may still warn; catch parse failures to fail fast
try {
SemgrexPattern p = SemgrexPattern.compile(expr);
} catch (RuntimeException e) {
throw new IllegalArgumentException("Bad semgrex: " + expr, e);
} Prevention
- Keep semgrex patterns in reviewed version-controlled files
- Re-validate all stored patterns after upgrading CoreNLP versions
- Read the logged expression + stack to pinpoint the offending fragment
- Test patterns against a small sample SemanticGraph
When it happens
Trigger: Parsing a semgrex pattern string via SemgrexPattern.compile that triggers a parser warning hook — e.g., deprecated or suspicious syntax the grammar recognizes but flags.
Common situations: Migrating old semgrex syntax to a newer parser version; typos in relation patterns like {} node specs; copy-pasted patterns from older papers/code.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- Use of & in semgrex patterns is now illegal. It is…
- Use of node conjugation (expressions such as '< [foo bar]'…
- Current stack
- Use of node conjugation (expressions such as '< [foo bar]'…
- Semgrex pattern asked for uniq of node which does not…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/18f7c4580c4f7000.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/SemgrexParser.jj:52
private String fullExpression(Token startToken) {
StringBuilder result = new StringBuilder();
for (Token p = startToken; p != null; p = p.next) {
if (p.specialToken != null) {
result.append(p.specialToken.image);
}
result.append(p.image);
}
return result.toString();
}
private void warnDeprecated(String warning, Token startToken) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
(new RuntimeException()).printStackTrace(pw);
String trace = sw.toString();
trace = trace.substring(trace.lastIndexOf("SemgrexParser"));
trace = trace.substring(trace.indexOf("at "));
log.warn(warning + "\n " + fullExpression(startToken) + "\n Current stack: " + trace);
}
}
PARSER_END(SemgrexParser)
SPECIAL_TOKEN:
{
< WHITESPACE: (" " | "\r" | "\t")+ >
}
TOKEN:
{
< UNIQ: "uniq" >
}
TOKEN:
{
< RELATION: "<" | ">" | ">>" | "<<" | "<>" | "==" | "$+" | "$-" | "$++" | "$--" | "." | ".." | "-" | "--" | ">++" | ">--" | "<++" | "<--" >View on GitHub (pinned to 1b7edd19c4)