{"record":{"id":"9eb04b5546bf0a8f","repo":"stanfordnlp/CoreNLP","slug":"relation-does-not-use-numeric-arguments","errorCode":null,"errorMessage":"Relation  does not use numeric arguments","messagePattern":"Relation  does not use numeric arguments","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java","lineNumber":1528,"sourceCode":"    }\n  }\n\n  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);","sourceCodeStart":1510,"sourceCodeEnd":1546,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java#L1510-L1546","documentation":"This ParseException is thrown by the numeric getRelation(String,String,int,String,String) overload when the relation is a known Semgrex operator but not one of the two numeric-limited relations ('>>' or '<<'). The overload exists specifically for counted grandparent/grandkid relations, so any other known operator passed with a count is rejected as misusing numeric arguments.","triggerScenarios":"Calling getRelation(\"$+\", null, 1, name, null), getRelation(\".\", null, 1, name, null), or getRelation(\">\", type, 2, name, null) - any known operator other than '>>'/'<<' with the int overload. Parsing patterns that attach a count to a non-countable operator, e.g. writing '>2' or '$+1' in a Semgrex expression.","commonSituations":"Users guessing syntax and appending numbers to operators to mean 'n hops'; porting patterns from other graph query languages where numeric repetition is generic; typos like '>' with stray digits from template generation.","solutions":["Remove the numeric argument, or restrict counts to '>>' and '<<' which are the only relations using them.","Use '>' / '<' nested twice (or composition) instead of counting other operators.","If calling getRelation directly, use the two-argument-name overload (reln, type, name, edgeName) for non-numeric relations.","Check isKnownRelation: only '>>' and '<<' are valid with the int overload."],"exampleFix":"// before\nGraphRelation r = GraphRelation.getRelation(\">\", null, 2, name, null); // throws\n// after\nGraphRelation r = GraphRelation.getRelation(\">\", null, name, null); // or use \">>\" for counted grandparents","handlingStrategy":"validation","validationCode":"boolean numericRelation(String reln) {\n  return reln.equals(\">>\") || reln.equals(\"<<\");\n}\n// route before calling:\n// if (numericRelation(reln)) use int overload; else use (reln, type, name, edgeName) overload","typeGuard":null,"tryCatchPattern":"try {\n  GraphRelation r = GraphRelation.getRelation(reln, type, num, name, null);\n} catch (ParseException e) {\n  if (e.getMessage().contains(\"does not use numeric arguments\")) {\n    r = GraphRelation.getRelation(reln, type, name, null);\n  }\n}","preventionTips":["Only pass the int overload for '>>' and '<<'.","Validate user patterns so digits following an operator are rejected unless the operator is >>/<<.","Test pattern compilation over the full operator list."],"tags":["java","parse-exception","semgrex","numeric-argument"],"backgroundTag":"invalid-argument-value","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"}