stanfordnlp/CoreNLP · error · SsurgeonParseException

SplitWord expected -exact or -regex with regex to determine…

Error message

SplitWord expected -exact or -regex with regex to determine which pieces to split the word into

What it means

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.

Solutions

  1. Provide at least one -exact value or one -regex pattern, e.g. -exact un -exact able
  2. Ensure your CLI/XML parsing collects all repeated -exact/-regex values into the nodePieces list
  3. Pass a non-empty List<String> as the second constructor argument

Example fix

// before
new SplitWord("w", new ArrayList<>(), 0, reln, null, true);
// after
new SplitWord("w", Arrays.asList("un", "do"), 0, reln, null, true);
Defensive patterns

Strategy: validation

Validate before calling

if (nodePieces == null || nodePieces.isEmpty()) throw new IllegalArgumentException("SplitWord requires at least one -exact or -regex value");

Try / catch

try { SplitWord sw = new SplitWord(node, pieces, headIndex, reln, names, exact); } catch (SsurgeonParseException e) { log.error("Provide -exact or -regex pieces: " + e.getMessage()); }

Prevention

When it happens

Trigger: Constructing SplitWord with nodePieces == null or an empty list — e.g. neither -exact nor -regex flags given, or the flags given with no values.

Common situations: 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.

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/2d7dabccd5f74c50. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java:55

 */
public class SplitWord extends SsurgeonEdit {
  public static final String LABEL = "splitWord";

  final String node;
  final List<Pattern> nodeRegex;
  final List<String> exactPieces;
  final int headIndex;
  final GrammaticalRelation relation;
  final Map<Integer, String> nodeNames;

  public SplitWord(String node, List<String> nodePieces, Integer headIndex, GrammaticalRelation relation, String nodeNames, boolean exactSplit) {
    if (node == null) {
      throw new SsurgeonParseException("SplitWord expected -node with the name of the matched node to split");
    }
    this.node = node;

    if (nodePieces == null || nodePieces.size() == 0) {
      throw new SsurgeonParseException("SplitWord expected -exact or -regex with regex to determine which pieces to split the word into");
    }
    if (nodePieces.size() == 1) {
      throw new SsurgeonParseException("SplitWord expected at least two -exact or -regex");
    }
    if (exactSplit) {
      this.exactPieces = new ArrayList<>(nodePieces);
      this.nodeRegex = null;
    } else {
      this.nodeRegex = new ArrayList<>();
      for (int i = 0; i < nodePieces.size(); ++i) {
        this.nodeRegex.add(Pattern.compile(nodePieces.get(i)));
      }
      this.exactPieces = null;
    }

    if (headIndex == null) {
      throw new SsurgeonParseException("SplitWord expected a -headIndex, 0-indexed for the word piece to use when chopping up the word");
    }

View on GitHub (pinned to 1b7edd19c4)