{"record":{"id":"19da078fc777ff2d","repo":"stanfordnlp/CoreNLP","slug":"found-both-regex-and-exact-in-the-splits-for-split","errorCode":null,"errorMessage":"Found both regex and exact in the splits for splitWord","messagePattern":"Found both regex and exact in the splits for splitWord","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java","lineNumber":681,"sourceCode":"          reln = GrammaticalRelation.valueOf(argsBox.reln);\n        }\n        return new RemoveEdge(reln, argsBox.govNodeName, argsBox.dep);\n      } else if (command.equalsIgnoreCase(RemoveNamedEdge.LABEL)) {\n        return new RemoveNamedEdge(argsBox.edge);\n      } else if (command.equalsIgnoreCase(KillAllIncomingEdges.LABEL)) {\n        if (argsBox.nodes.size() != 1) {\n          throw new SsurgeonParseException(\"Cannot make a KillAllIncomingEdges out of \" + argsBox.nodes.size() + \" nodes\");\n        }\n        return new KillAllIncomingEdges(argsBox.nodes.get(0));\n      } else if (command.equalsIgnoreCase(CombineMWT.LABEL)) {\n        return new CombineMWT(argsBox.nodes, argsBox.annotations.get(\"word\"));\n      } else if (command.equalsIgnoreCase(SetPhraseHead.LABEL)) {\n        GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);\n        return new SetPhraseHead(argsBox.nodes, argsBox.headIndex, reln, argsBox.weight);\n      } else if (command.equalsIgnoreCase(SplitWord.LABEL)) {\n        GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);\n        if (argsBox.regex.size() > 0 && argsBox.exact.size() > 0) {\n          throw new SsurgeonParseException(\"Found both regex and exact in the splits for splitWord\");\n        }\n        if (argsBox.regex.size() > 0) {\n          return new SplitWord(argsBox.nodes.get(0), argsBox.regex, argsBox.headIndex, reln, argsBox.name, false);\n        } else {\n          return new SplitWord(argsBox.nodes.get(0), argsBox.exact, argsBox.headIndex, reln, argsBox.name, true);\n        }\n      } else if (command.equalsIgnoreCase(ReindexGraph.LABEL)) {\n        return new ReindexGraph();\n      }\n      throw new SsurgeonParseException(\"Error in SsurgeonEdit.parseEditLine: command '\"+command+\"' is not supported\");\n    } catch (SsurgeonParseException e) {\n      throw new SsurgeonParseException(\"Unable to process Ssurgeon edit line: \" + editLine, e);\n    }\n  }\n\n  //public static SsurgeonPattern fromXML(String xmlString) throws Exception {\n  //SAXBuilder builder = new SAXBuilder();\n  //Document jdomDoc = builder.build(xmlString);","sourceCodeStart":663,"sourceCodeEnd":699,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java#L663-L699","documentation":"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.","triggerScenarios":"Edit line 'splitWord -node:w -regex:... -exact:...' — argsBox.regex and argsBox.exact both non-empty triggers the throw.","commonSituations":"Merging two split rules into one line by concatenation, or an auto-generated rule that appends both kinds of splits without checking.","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"],"exampleFix":"# before\nsplitWord -node:word -regex:\"a,b\" -exact:\"ab\"\n# after\nsplitWord -node:word -regex:\"a,b\"","handlingStrategy":"validation","validationCode":"boolean validSplitWord(String line) {\n  boolean hasRegex = line.contains(\"-regex:\");\n  boolean hasExact = line.contains(\"-exact:\");\n  return line.startsWith(\"splitWord\") && hasRegex ^ hasExact;\n}","typeGuard":null,"tryCatchPattern":"try {\n  SsurgeonEdit e = Ssurgeon.parseEditLine(line);\n} catch (SsurgeonParseException ex) {\n  throw new IllegalArgumentException(\"splitWord: choose -regex OR -exact: \" + line, ex);\n}","preventionTips":["Treat -regex and -exact as mutually exclusive when generating rules","Split mixed requirements into separate rules","Add a unit test covering each splitWord rule"],"tags":["java","ssurgeon","parser","conflicting-options"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}