stanfordnlp/CoreNLP · error · ParseException
Unrecognized compound relation
Error message
Unrecognized compound relation ${s} ${arg} What it means
Relation.getRelation() also handles compound relations that take an argument (e.g. <<#, <<:, <<<); an unrecognized compound symbol combined with its argument falls to the default branch and throws ParseException naming both the symbol and the argument. It indicates an invalid compound relation in a tregex query.
Solutions
- Fix the compound relation symbol to a supported one (e.g. <<:, <<#, <<<, <<,), keeping its argument intact
- Validate the argument (e.g. integer index for <<<) along with the symbol
- Consult the Relation switch cases for the exact supported symbols in your version
- Upgrade CoreNLP if the query syntax comes from a newer release
Example fix
// before
Relation r = Relation.getRelation("<<<x", "3", basicCatFunction, headFinder); // throws
// after
Relation r = Relation.getRelation("<<<", "3", basicCatFunction, headFinder); Defensive patterns
Strategy: try-catch
Validate before calling
Set<String> compoundRels = Set.of("<<#", "<<,", ">>#", ">>,", "<<:", ">>:", "<<<", "<<:");
if (!compoundRels.contains(s)) throw new IllegalArgumentException("Unknown compound relation: " + s); Try / catch
try {
Relation r = Relation.getRelation(s, arg, basicCatFunction, headFinder);
} catch (ParseException e) {
throw new TregexQueryException("Invalid compound relation '" + s + "' with arg '" + arg + "'", e);
} Prevention
- Double-check angle-bracket counts in compound operators (<< vs <<<)
- Validate integer arguments for indexed relations before calling
- Test queries against a small fixture tree in CI
When it happens
Trigger: A tregex query contains a compound relation symbol not in the supported set, e.g. getRelation("<<x", "NP", basicCatFunction, headFinder) with a typo or version-mismatched operator.
Common situations: Typos such as '<<<' vs '<<' variants; copying queries from tregex tutorials for other languages/tools; running queries written for newer CoreNLP releases.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Unrecognized simple relation
- Unknown multi relation
- Parsing failed. Error:
- Couldn't parse + json
- GraphRelation had both = and ~ set, but the names were…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/1a7247ec39e49dfc.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/trees/tregex/Relation.java:166
r = new IthChildOf(Integer.parseInt(arg));
break;
case "<+":
r = new UnbrokenCategoryDominates(arg, basicCatFunction);
break;
case ">+":
r = new UnbrokenCategoryIsDominatedBy(arg, basicCatFunction);
break;
case ".+":
r = new UnbrokenCategoryPrecedes(arg, basicCatFunction);
break;
case ",+":
r = new UnbrokenCategoryFollows(arg, basicCatFunction);
break;
case "<<<":
r = new AncestorOfIthLeaf(Integer.parseInt(arg));
break;
default:
throw new ParseException("Unrecognized compound relation " + s + ' '
+ arg);
}
return Interner.globalIntern(r);
}
/**
* Produce a TregexPattern which represents the given MULTI_RELATION
* and its children
*/
static TregexPattern constructMultiRelation(String s, List<DescriptionPattern> children,
Function<String, String> basicCatFunction,
HeadFinder headFinder) throws ParseException {
if (s.equals("<...")) {
List<TregexPattern> newChildren = Generics.newArrayList();
for (int i = 0; i < children.size(); ++i) {
Relation rel = getRelation("<", Integer.toString(i + 1), basicCatFunction, headFinder);
DescriptionPattern oldChild = children.get(i);
TregexPattern newChild = new DescriptionPattern(rel, oldChild);View on GitHub (pinned to 1b7edd19c4)