{"record":{"id":"2d7dabccd5f74c50","repo":"stanfordnlp/CoreNLP","slug":"splitword-expected-exact-or-regex-with-regex-to","errorCode":null,"errorMessage":"SplitWord expected -exact or -regex with regex to determine which pieces to split the word into","messagePattern":"SplitWord expected -exact or -regex with regex to determine which pieces to split the word into","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java","lineNumber":55,"sourceCode":" */\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;\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    }","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java#L37-L73","documentation":"SplitWord needs the list of word pieces to split the matched node's word into, supplied via -exact (literal pieces) or -regex (a regex whose groups define pieces). If nodePieces is null or empty, the constructor throws SsurgeonParseException because there is nothing to split into.","triggerScenarios":"Constructing SplitWord with nodePieces == null or an empty list — e.g. neither -exact nor -regex flags given, or the flags given with no values.","commonSituations":"Omitting both -exact and -regex when writing the ssurgeon rule; an argument parser that swallows repeated flags and yields an empty list; building SplitWord in Java without populating the pieces list.","solutions":["Provide at least one -exact value or one -regex pattern, e.g. -exact un -exact able","Ensure your CLI/XML parsing collects all repeated -exact/-regex values into the nodePieces list","Pass a non-empty List<String> as the second constructor argument"],"exampleFix":"// before\nnew SplitWord(\"w\", new ArrayList<>(), 0, reln, null, true);\n// after\nnew SplitWord(\"w\", Arrays.asList(\"un\", \"do\"), 0, reln, null, true);","handlingStrategy":"validation","validationCode":"if (nodePieces == null || nodePieces.isEmpty()) throw new IllegalArgumentException(\"SplitWord requires at least one -exact or -regex value\");","typeGuard":null,"tryCatchPattern":"try { SplitWord sw = new SplitWord(node, pieces, headIndex, reln, names, exact); } catch (SsurgeonParseException e) { log.error(\"Provide -exact or -regex pieces: \" + e.getMessage()); }","preventionTips":["Always supply -exact and/or -regex flags with values","Verify your argument parser collects repeated flags into the list","Unit-test SplitWord construction with representative piece lists"],"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"}