stanfordnlp/CoreNLP · error · SsurgeonParseException

Relation not specified for AddEdge

Error message

Relation not specified for AddEdge

What it means

When parsing an AddEdge edit, parseEditLine requires -reln specifying the GrammaticalRelation of the new edge. If argsBox.reln is null, SsurgeonParseException('Relation not specified for AddEdge') is thrown.

Solutions

  1. Add -reln <relation> to the addedge line, e.g. -reln conj:and.
  2. Ensure the relation name exists in the Universal/GrammaticalRelation set for your language.
  3. Verify flag/value pairing by simplifying the line to minimal flags and re-adding arguments one at a time.

Example fix

// before
addedge -gov root -dep child
// after
addedge -gov root -dep child -reln punct
Defensive patterns

Strategy: validation

Validate before calling

if (line.startsWith("addedge") && !line.matches(".*-reln\\s+\\S+.*"))
  throw new IllegalArgumentException("addedge line missing -reln: " + line);

Try / catch

try { parseEditLine(line, attrs, lang); } catch (SsurgeonParseException e) { if (e.getMessage().equals("Relation not specified for AddEdge")) log.error("Add -reln to: " + line); }

Prevention

When it happens

Trigger: An 'addedge -gov ... -dep ...' line missing -reln; or -reln present but dropped due to malformed quote pairing in parseArgs leaving argsBox.reln null.

Common situations: Hand-written addedge rules omitting the relation; copying an addedge template and deleting the -reln line; argument-pair misalignment caused by an unmatched quote earlier in the line.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/499bb15b657ee56a. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java:623

        return new SetRoots(newRoots);
      } else if (command.equalsIgnoreCase(KillNonRootedNodes.LABEL)) {
        return new KillNonRootedNodes();
      }

      // Parse the arguments based upon the type of command to execute.
      final SsurgeonArgs argsBox = parseArgsBox(tuples1.length == 1 ? "" : tuples1[1], attributeArgs);

      if (command.equalsIgnoreCase(AddDep.LABEL)) {
        if (argsBox.reln == null) {
          throw new SsurgeonParseException("Relation not specified for AddDep");
        }
        GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);
        return new AddDep(argsBox.govNodeName, reln, argsBox.annotations, argsBox.position);
      } else if (command.equalsIgnoreCase(AddNode.LABEL)) {
        return AddNode.createAddNode(argsBox.nodeString, argsBox.name);
      } else if (command.equalsIgnoreCase(AddEdge.LABEL)) {
        if (argsBox.reln == null) {
          throw new SsurgeonParseException("Relation not specified for AddEdge");
        }
        GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);
        return new AddEdge(argsBox.govNodeName, argsBox.dep, reln, argsBox.weight);
      } else if (command.equalsIgnoreCase(ReattachNamedEdge.LABEL)) {
          return new ReattachNamedEdge(argsBox.edge, argsBox.govNodeName, argsBox.dep);
      } else if (command.equalsIgnoreCase(DeleteGraphFromNode.LABEL)) {
        if (argsBox.nodes.size() != 1) {
          throw new SsurgeonParseException("Cannot make a DeleteGraphFromNode out of " + argsBox.nodes.size() + " nodes");
        }
        return new DeleteGraphFromNode(argsBox.nodes.get(0));
      } else if (command.equalsIgnoreCase(DeleteLeaf.LABEL)) {
        if (argsBox.nodes.size() != 1) {
          throw new SsurgeonParseException("Cannot make a DeleteLeaf out of " + argsBox.nodes.size() + " nodes");
        }
        return new DeleteLeaf(argsBox.nodes.get(0));
      } else if (command.equalsIgnoreCase(EditNode.LABEL)) {
        if (argsBox.nodes.size() != 1) {
          throw new SsurgeonParseException("Cannot make an EditNode out of " + argsBox.nodes.size() + " nodes.  Please use exactly one -node");

View on GitHub (pinned to 1b7edd19c4)