stanfordnlp/CoreNLP · error · SsurgeonParseException

Cannot combine MWT out of only

Error message

Cannot combine MWT out of only ${names.size()} words

What it means

CombineMWT joins at least two adjacent words into one multi-word token (MWT). The constructor throws SsurgeonParseException if fewer than two node names are supplied, because a "combination" of a single word is meaningless and would corrupt MWT bookkeeping.

Solutions

  1. Supply at least two node names in the list passed to CombineMWT.
  2. Add a size check (names.size() >= 2) before constructing the operation and emit a clearer error earlier.
  3. If only one word matches, skip emitting the combinemwt instruction entirely.

Example fix

// before
new CombineMWT(Collections.singletonList("w1"), "combined");

// after
List<String> names = List.of("w1", "w2");
if (names.size() >= 2) {
  new CombineMWT(names, "combined");
}
Defensive patterns

Strategy: validation

Validate before calling

// Java
if (names == null || names.size() < 2) {
  throw new IllegalArgumentException("CombineMWT requires at least 2 node names");
}

Try / catch

// Java
try {
  CombineMWT op = new CombineMWT(names, word);
} catch (SsurgeonParseException e) {
  log.warning("Skipping combinemwt: " + e.getMessage());
}

Prevention

When it happens

Trigger: Constructing new CombineMWT(List.of("one"), word) or writing an Ssurgeon combinemwt instruction with only one node name; thrown from the CombineMWT constructor.

Common situations: Programmatically generating combinemwt rules where an empty/short match list slips through; hand-editing .ssurgeon files and deleting one of the node names.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/CombineMWT.java:35

 *<br>
 * For the most part, the nodes themselves are unchanged, but the
 * nodes now have the CoreAnnotations representing MWTness added
 *<br>
 * This is a convenience operation which exists because the basic
 * version of it using EditNode is a bit of a pain
 *
 * @author John Bauer
 */
public class CombineMWT extends SsurgeonEdit {
  public static final String LABEL = "combineMWT";
  final List<String> names;
  final String word;

  public CombineMWT(List<String> names, String word) {
    this.names = new ArrayList<>(names);
    this.word = word;
    if (names.size() < 2) {
      throw new SsurgeonParseException("Cannot combine MWT out of only " + names.size() + " words");
    }
  }

  /**
   * Emits a parseable instruction string.
   */
  @Override
  public String toEditString() {
    StringWriter buf = new StringWriter();
    buf.write(LABEL);
    for (String name : names) {
      buf.write("\t");
      buf.write(name);
    }
    if (word != null && !word.equals("")) {
      buf.write("\t");
      buf.write(word);
    }

View on GitHub (pinned to 1b7edd19c4)