{"record":{"id":"bc92a1d87c72d63f","repo":"stanfordnlp/CoreNLP","slug":"unrecognized-compound-relation","errorCode":null,"errorMessage":"Unrecognized compound relation   ","messagePattern":"Unrecognized compound relation   ","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java","lineNumber":1531,"sourceCode":"  public static GraphRelation getRelation(String reln,\n                                          String type,\n                                          int num,\n                                          String name,\n                                          String edgeName) throws ParseException {\n    if (edgeName != null) {\n      throw new ParseException(\"Relation \" + reln + \" does not allow for named edges\");\n    }\n    if (reln == null && type == null)\n      return null;\n    if (reln.equals(\">>\"))\n      return new LIMITED_GRANDPARENT(type, name, num, num);\n    else if (reln.equals(\"<<\"))\n      return new LIMITED_GRANDKID(type, name, num, num);\n    else if (isKnownRelation(reln))\n      throw new ParseException(\"Relation \" + reln +\n                               \" does not use numeric arguments\");\n    else //error\n      throw new ParseException(\"Unrecognized compound relation \" + reln + \" \"\n                               + type);\n  }\n\n  public static GraphRelation getRelation(String reln,\n                                          String type,\n                                          int num, int num2,\n                                          String name,\n                                          String edgeName) throws ParseException {\n    if (edgeName != null) {\n      throw new ParseException(\"Relation \" + reln + \" does not allow for named edges\");\n    }\n    if (reln == null && type == null)\n      return null;\n    if (reln.equals(\">>\"))\n      return new LIMITED_GRANDPARENT(type, name, num, num2);\n    else if (reln.equals(\"<<\"))\n      return new LIMITED_GRANDKID(type, name, num, num2);\n    else if (isKnownRelation(reln))","sourceCodeStart":1513,"sourceCodeEnd":1549,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java#L1513-L1549","documentation":"This ParseException is the final else branch of the numeric getRelation(String,String,int,String,String) overload: the relation is neither '>>' nor '<<' nor any known relation, so it is an unrecognized compound relation and the reln string plus the relation type are reported. It means the parser encountered an operator string that does not exist in Semgrex at all while a numeric argument was present.","triggerScenarios":"Calling getRelation(\">>*\", type, 2, name, null), getRelation(\"~obj\", type, 1, name, null), or any misspelled/unknown operator with the int overload. Parsing a Semgrex pattern containing a malformed operator such as '<>>' routed into the compound relation path.","commonSituations":"Typos in hand-written Semgrex patterns; using relation syntax from a different version or a different library (e.g. tregex-style operators); copy-pasted patterns from documentation of newer CoreNLP versions into older jars.","solutions":["Check the relation spelling against GraphRelation.isKnownRelation ('>', '<', '>>', '<<', '<>', '@', '==', '$+', '$++', '$-', '$--', '.', '..', '-', '--', '>++', '>--', '<++', '<--').","If a count is intended, only '>>' and '<<' accept it; fix the operator to one of those.","Upgrade the CoreNLP version if the relation was added in a newer release.","Print the full pattern and locate the malformed operator near the numeric argument."],"exampleFix":"// before\nGraphRelation r = GraphRelation.getRelation(\"<>>\", null, 2, name, null); // throws\n// after\nGraphRelation r = GraphRelation.getRelation(\">>\", null, 2, name, null); // corrected operator","handlingStrategy":"validation","validationCode":"static final Set<String> KNOWN = Set.of(\">\", \"<\", \">>\", \"<<\", \"<>\", \"@\", \"==\",\n    \"$+\", \"$++\", \"$-\", \"$--\", \".\", \"..\", \"-\", \"--\", \">++\", \">--\", \"<++\", \"<--\");\nif (!KNOWN.contains(reln)) {\n  throw new IllegalArgumentException(\"Unrecognized relation: \" + reln);\n}","typeGuard":null,"tryCatchPattern":"try {\n  GraphRelation r = GraphRelation.getRelation(reln, type, num, name, null);\n} catch (ParseException e) {\n  if (e.getMessage().startsWith(\"Unrecognized compound relation\")) {\n    throw new IllegalArgumentException(\"Invalid Semgrex operator in pattern: \" + reln, e);\n  }\n}","preventionTips":["Whitelist relation strings against isKnownRelation before invoking getRelation.","Fail fast in pattern parsers on unrecognized operator tokens with a clear user-facing message.","When copying patterns across tools/versions, re-validate each operator against the target CoreNLP version."],"tags":["java","parse-exception","semgrex","unknown-relation"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}