{"record":{"id":"557a1772580b6291","repo":"stanfordnlp/CoreNLP","slug":"splitword-expected-at-least-two-exact-or-regex","errorCode":null,"errorMessage":"SplitWord expected at least two -exact or -regex","messagePattern":"SplitWord expected at least two -exact or -regex","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java","lineNumber":58,"sourceCode":"\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;\n    }\n\n    if (headIndex == null) {\n      throw new SsurgeonParseException(\"SplitWord expected a -headIndex, 0-indexed for the word piece to use when chopping up the word\");\n    }\n    this.headIndex = headIndex;\n\n    if (relation == null) {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java#L40-L76","documentation":"Splitting a word must produce at least two pieces — otherwise the operation is a no-op and ambiguous. If nodePieces has exactly one element, the SplitWord constructor throws SsurgeonParseException telling the user to supply at least two -exact or -regex values.","triggerScenarios":"Calling new SplitWord(...) with a single-element nodePieces list, or specifying exactly one -exact/-regex flag on the ssurgeon command.","commonSituations":"Testing a split with a single piece to see what happens; an XML rule where the second -exact line was accidentally deleted; a regex with no capture groups producing one effective piece.","solutions":["Supply at least two pieces: e.g. -exact micro -exact soft, or a -regex with two or more capture groups","If you truly need no split, remove the SplitWord operation from the rule rather than passing one piece","Count the capture groups in your -regex; each group becomes a piece, so use a group count >= 2"],"exampleFix":"// before\nnew SplitWord(\"w\", List.of(\"soft\"), 0, reln, null, true);\n// after\nnew SplitWord(\"w\", List.of(\"micro\", \"soft\"), 0, reln, null, true);","handlingStrategy":"validation","validationCode":"if (nodePieces != null && nodePieces.size() < 2) throw new IllegalArgumentException(\"SplitWord needs at least two pieces; remove the operation if no split is wanted\");","typeGuard":null,"tryCatchPattern":"try { SplitWord sw = new SplitWord(node, pieces, headIndex, reln, names, exact); } catch (SsurgeonParseException e) { log.error(\"Need >= 2 -exact/-regex: \" + e.getMessage()); }","preventionTips":["Count regex capture groups; require >= 2 for -regex splits","Never pass a single-piece list; delete the operation instead","Review rule XML diff for accidentally removed -exact lines"],"tags":["ssurgeon","constructor","invalid-argument-value"],"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-17T15:17:12.973Z"}