stanfordnlp/CoreNLP · error · SsurgeonParseException
Found both regex and exact in the splits for splitWord
Error message
Found both regex and exact in the splits for splitWord
What it means
The splitWord (SplitWord) edit splits a matched word into pieces specified either by regex patterns or by exact string matches, but not both. parseEditLine throws SsurgeonParseException when the edit line contains both -regex and -exact split specifications.
Solutions
- Remove either the -regex or the -exact arguments, keeping one split style
- Split into two separate edit lines (or rules) if both split kinds are genuinely needed
- Check rule-generation code that emits splitWord lines so it writes mutually exclusive specs
Example fix
# before splitWord -node:word -regex:"a,b" -exact:"ab" # after splitWord -node:word -regex:"a,b"
Defensive patterns
Strategy: validation
Validate before calling
boolean validSplitWord(String line) {
boolean hasRegex = line.contains("-regex:");
boolean hasExact = line.contains("-exact:");
return line.startsWith("splitWord") && hasRegex ^ hasExact;
} Try / catch
try {
SsurgeonEdit e = Ssurgeon.parseEditLine(line);
} catch (SsurgeonParseException ex) {
throw new IllegalArgumentException("splitWord: choose -regex OR -exact: " + line, ex);
} Prevention
- Treat -regex and -exact as mutually exclusive when generating rules
- Split mixed requirements into separate rules
- Add a unit test covering each splitWord rule
When it happens
Trigger: Edit line 'splitWord -node:w -regex:... -exact:...' — argsBox.regex and argsBox.exact both non-empty triggers the throw.
Common situations: Merging two split rules into one line by concatenation, or an auto-generated rule that appends both kinds of splits without checking.
Related errors
- Cannot make a KillAllIncomingEdges out of " +…
- Cannot make a MergeNodes out of fewer than 2 nodes (got " +…
- Error in SsurgeonEdit.parseEditLine: command '"+command+"'…
- Unable to process Ssurgeon edit line: " + editLine
- At least two of lang (" + lang + "), openClassTags (length…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/19da078fc777ff2d.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java:681
reln = GrammaticalRelation.valueOf(argsBox.reln);
}
return new RemoveEdge(reln, argsBox.govNodeName, argsBox.dep);
} else if (command.equalsIgnoreCase(RemoveNamedEdge.LABEL)) {
return new RemoveNamedEdge(argsBox.edge);
} else if (command.equalsIgnoreCase(KillAllIncomingEdges.LABEL)) {
if (argsBox.nodes.size() != 1) {
throw new SsurgeonParseException("Cannot make a KillAllIncomingEdges out of " + argsBox.nodes.size() + " nodes");
}
return new KillAllIncomingEdges(argsBox.nodes.get(0));
} else if (command.equalsIgnoreCase(CombineMWT.LABEL)) {
return new CombineMWT(argsBox.nodes, argsBox.annotations.get("word"));
} else if (command.equalsIgnoreCase(SetPhraseHead.LABEL)) {
GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);
return new SetPhraseHead(argsBox.nodes, argsBox.headIndex, reln, argsBox.weight);
} else if (command.equalsIgnoreCase(SplitWord.LABEL)) {
GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);
if (argsBox.regex.size() > 0 && argsBox.exact.size() > 0) {
throw new SsurgeonParseException("Found both regex and exact in the splits for splitWord");
}
if (argsBox.regex.size() > 0) {
return new SplitWord(argsBox.nodes.get(0), argsBox.regex, argsBox.headIndex, reln, argsBox.name, false);
} else {
return new SplitWord(argsBox.nodes.get(0), argsBox.exact, argsBox.headIndex, reln, argsBox.name, true);
}
} else if (command.equalsIgnoreCase(ReindexGraph.LABEL)) {
return new ReindexGraph();
}
throw new SsurgeonParseException("Error in SsurgeonEdit.parseEditLine: command '"+command+"' is not supported");
} catch (SsurgeonParseException e) {
throw new SsurgeonParseException("Unable to process Ssurgeon edit line: " + editLine, e);
}
}
//public static SsurgeonPattern fromXML(String xmlString) throws Exception {
//SAXBuilder builder = new SAXBuilder();
//Document jdomDoc = builder.build(xmlString);View on GitHub (pinned to 1b7edd19c4)