stanfordnlp/CoreNLP · error · SsurgeonParseException

SplitWord got an index in -name which was larger than the…

Error message

SplitWord got an index in -name which was larger than the largest possible split piece, ${idx} (this is 0-indexed)

What it means

SplitWord parses a -name argument of the form 'idx=name' mapping split-piece indices to new node names. SsurgeonParseException is thrown when the index given is >= the number of split pieces the word was actually split into. Indices are 0-indexed, so the largest legal index is pieces.size()-1.

Solutions

  1. Lower the -name index to be within 0..(number of split pieces - 1).
  2. Check the split regex/pattern on the -node word to confirm how many pieces it actually produces for your input.
  3. If using 1-based numbering in your head, subtract 1 from every -name index.
  4. Wrap rule loading in a try-catch for SsurgeonParseException and report the offending edit line.

Example fix

// before
splitword -node node -pattern "-" -name 2=part
// after (word has only 2 pieces: 0 and 1)
splitword -node node -pattern "-" -name 1=part
Defensive patterns

Strategy: validation

Validate before calling

String[] pieces = word.split(pattern);
for (String nameSpec : nameSpecs) {
  int idx = Integer.parseInt(nameSpec.split("=", 2)[0]);
  if (idx < 0 || idx >= pieces.length)
    throw new IllegalArgumentException("-name index " + idx + " out of range for " + pieces.length + " pieces");
}

Try / catch

try { Ssurgeon.add_compound_rules(ruleFile); } catch (SsurgeonParseException e) { log.error("Bad splitword -name in rule: " + e.getMessage()); }

Prevention

When it happens

Trigger: Calling SplitWord (via an ssurgeon edit line like 'splitword -node ... -name 3=foo') where the node's word splits into fewer pieces than the index used, e.g. -name 2=x on a word that splits into only 2 pieces (indices 0 and 1). Also triggered by typo'd indices or assuming 1-based indexing.

Common situations: Hand-written Ssurgeon rule files where the -name index assumes a different split result than the regex produces; off-by-one mistakes because the message says '0-indexed'; rule templates reused against words with fewer delimiters.

Related errors


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

Appendix: source

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

    }
    this.headIndex = headIndex;

    if (relation == null) {
      throw new SsurgeonParseException("SplitWord expected a -reln to represent the dependency to use for the new words");
    }
    this.relation = relation;

    if (nodeNames != null) {
      String[] namePieces = nodeNames.split(",");
      this.nodeNames = new HashMap<>();
      for (String namePiece : namePieces) {
        String[] pieces = namePiece.split("=", 2);
        if (pieces.length < 2) {
          throw new SsurgeonParseException("SplitWord got a -name parameter which did not have a number for one of the names.  Should look like 0=foo,1=bar");
        }
        int idx = Integer.valueOf(pieces[0]);
        if (idx >= nodePieces.size()) {
          throw new SsurgeonParseException("SplitWord got an index in -name which was larger than the largest possible split piece, " + idx + " (this is 0-indexed)");
        }
        this.nodeNames.put(idx, pieces[1]);
      }
    } else {
      this.nodeNames = Collections.emptyMap();
    }
  }

  @Override
  public String toEditString() {
    StringWriter buf = new StringWriter();
    buf.write(LABEL);
    buf.write("\t");
    buf.write("-node " + node + "\t");
    if (nodeRegex != null) {
      for (Pattern regex : nodeRegex) {
        buf.write("-regex " + regex + "\t");
      }

View on GitHub (pinned to 1b7edd19c4)