{"record":{"id":"d8c3ddda40dccd48","repo":"stanfordnlp/CoreNLP","slug":"graphrelation-had-both-and-set-but-the-names","errorCode":null,"errorMessage":"GraphRelation had both = and ~ set, but the names were different!  ","messagePattern":"GraphRelation had both = and ~ set, but the names were different!  ","errorType":"validation","errorClass":"SemgrexParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java","lineNumber":63,"sourceCode":"  /**\n   * Returns <code>true</code> iff this <code>GraphRelation</code> holds between\n   * the given pair of nodes in the given semantic graph.\n   */\n  abstract boolean satisfies(IndexedWord n1, IndexedWord n2, SemanticGraph sg);\n\n  /**\n   * For a given node and its root, returns an {@link Iterator} over the nodes\n   * of the semantic graph that satisfy the relation.\n   */\n  abstract Iterator<IndexedWord> searchNodeIterator(IndexedWord node, SemanticGraph sg);\n\n  private GraphRelation(String symbol, String type, String name, String edgeName) {\n    this.symbol = symbol;\n    this.type   = getPattern(type);\n    this.rawType = type;\n    this.edgeName = edgeName;\n    if (name != null && edgeName != null && !name.equals(edgeName)) {\n      throw new SemgrexParseException(\"GraphRelation had both = and ~ set, but the names were different!  \" + this.toString());\n    }\n    if (name != null) {\n      this.name = name;\n    } else {\n      this.name = edgeName;\n    }\n  }\n\n  private GraphRelation(String symbol, String type, String name) {\n    this(symbol, type, name, null);\n  }\n\n  private GraphRelation(String symbol, String type) {\n    this(symbol, type, null);\n  }\n\n  private GraphRelation(String symbol) {\n    this(symbol, null);","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java#L45-L81","documentation":"The GraphRelation constructor throws SemgrexParseException when both a node-name binding (=name) and an edge-name binding (~name) are present but differ. A GraphRelation can only carry one consistent name; conflicting names would make the pattern ambiguous.","triggerScenarios":"Parsing a Semgrex relation like \">=foo~bar\" where the = name and the ~ edgeName are both set to different strings, via GraphRelation.createRelation or the Semgrex parser.","commonSituations":"Typo in a hand-written Semgrex pattern assigning different names to the node and the edge; generated patterns concatenating name fragments incorrectly.","solutions":["Use the same name for both = and ~ bindings, or drop one of them","Edit the Semgrex pattern string so the node name (=x) and edge name (~x) match","If names must differ, keep only the one you intend to bind"],"exampleFix":"// before\nString pattern = \"{word:dog} >=subj=nsubj~edge\";\n// after\nString pattern = \"{word:dog} >=subj=nsubj~subj\";","handlingStrategy":"try-catch","validationCode":"if (name != null && edgeName != null && !name.equals(edgeName)) throw new IllegalArgumentException(\"= and ~ names must match: \" + name + \" vs \" + edgeName);","typeGuard":null,"tryCatchPattern":"try { GraphRelation r = GraphRelation.createRelation(reln, type, name, edgeName); } catch (SemgrexParseException e) { log.error(\"Inconsistent pattern names: \" + e.getMessage()); }","preventionTips":["Use identical names for = (node) and ~ (edge) bindings in Semgrex patterns","Validate pattern strings with the Semgrex parser before deploying them in configs","Keep name tokens generated from one variable so they cannot diverge"],"tags":["java","semgrex","parse-error"],"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"}