{"record":{"id":"5f3a672bbdbc5e88","repo":"stanfordnlp/CoreNLP","slug":"splitword-expected-node-with-the-name-of-the-matc","errorCode":null,"errorMessage":"SplitWord expected -node with the name of the matched node to split","messagePattern":"SplitWord expected -node with the name of the matched node to split","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java","lineNumber":50,"sourceCode":" *   splitWord -node split -regex ^(foo)bar$ -regex ^foo(bar)$ -reln dep -headIndex 1 -name 0=asdf\n *   editNode -node asdf -pos ADJ\n * </pre>\n *\n * @author John Bauer\n */\npublic class SplitWord extends SsurgeonEdit {\n  public static final String LABEL = \"splitWord\";\n\n  final String node;\n  final List<Pattern> nodeRegex;\n  final List<String> exactPieces;\n  final int headIndex;\n  final GrammaticalRelation relation;\n  final Map<Integer, String> nodeNames;\n\n  public SplitWord(String node, List<String> nodePieces, Integer headIndex, GrammaticalRelation relation, String nodeNames, boolean exactSplit) {\n    if (node == null) {\n      throw new SsurgeonParseException(\"SplitWord expected -node with the name of the matched node to split\");\n    }\n    this.node = node;\n\n    if (nodePieces == null || nodePieces.size() == 0) {\n      throw new SsurgeonParseException(\"SplitWord expected -exact or -regex with regex to determine which pieces to split the word into\");\n    }\n    if (nodePieces.size() == 1) {\n      throw new SsurgeonParseException(\"SplitWord expected at least two -exact or -regex\");\n    }\n    if (exactSplit) {\n      this.exactPieces = new ArrayList<>(nodePieces);\n      this.nodeRegex = null;\n    } else {\n      this.nodeRegex = new ArrayList<>();\n      for (int i = 0; i < nodePieces.size(); ++i) {\n        this.nodeRegex.add(Pattern.compile(nodePieces.get(i)));\n      }\n      this.exactPieces = null;","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java#L32-L68","documentation":"The SplitWord constructor requires the name of a semgrex-matched node to split, passed as the 'node' parameter (from the -node flag). If it is null, SsurgeonParseException is thrown at construction time — no graph edit is attempted.","triggerScenarios":"Building a SplitWord ssurgeon operation (programmatically or via Ssurgeon.fromXML) without supplying the -node argument, or supplying it with a null/empty value.","commonSituations":"Hand-editing an ssurgeon XML rule and dropping the -node attribute; constructing SplitWord directly in Java with null as the first argument; a parser that fails to read the -node flag from the command line.","solutions":["Add the -node flag with the name of the matched node, e.g. -node splitme, matching a named node in the semgrex pattern","Check the ssurgeon XML/args parsing path actually forwards the node value into the SplitWord constructor","In custom code, pass the same node name used in the semgrex pattern"],"exampleFix":"// before\nSplitWord sw = new SplitWord(null, pieces, 0, reln, null, true);\n// after\nSplitWord sw = new SplitWord(\"target\", pieces, 0, reln, null, true); // 'target' is a named semgrex node","handlingStrategy":"validation","validationCode":"if (node == null || node.isEmpty()) throw new IllegalArgumentException(\"SplitWord requires -node with a matched node name\");","typeGuard":null,"tryCatchPattern":"try { SplitWord sw = new SplitWord(node, pieces, headIndex, reln, names, exact); } catch (SsurgeonParseException e) { log.error(\"Bad SplitWord spec: \" + e.getMessage()); }","preventionTips":["Always pass the -node flag naming a node from the semgrex pattern","Validate ssurgeon XML rules against the expected SplitWord attributes before running","Construct SplitWord objects via a builder/helper that enforces required fields"],"tags":["ssurgeon","constructor","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}