{"record":{"id":"da1e1fe49367b4ec","repo":"stanfordnlp/CoreNLP","slug":"splitword-got-a-name-parameter-which-did-not-have","errorCode":null,"errorMessage":"SplitWord got a -name parameter which did not have a number for one of the names.  Should look like 0=foo,1=bar","messagePattern":"SplitWord got a -name parameter which did not have a number for one of the names\\.  Should look like 0=foo,1=bar","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java","lineNumber":87,"sourceCode":"    }\n\n    if (headIndex == null) {\n      throw new SsurgeonParseException(\"SplitWord expected a -headIndex, 0-indexed for the word piece to use when chopping up the word\");\n    }\n    this.headIndex = headIndex;\n\n    if (relation == null) {\n      throw new SsurgeonParseException(\"SplitWord expected a -reln to represent the dependency to use for the new words\");\n    }\n    this.relation = relation;\n\n    if (nodeNames != null) {\n      String[] namePieces = nodeNames.split(\",\");\n      this.nodeNames = new HashMap<>();\n      for (String namePiece : namePieces) {\n        String[] pieces = namePiece.split(\"=\", 2);\n        if (pieces.length < 2) {\n          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\");\n        }\n        int idx = Integer.valueOf(pieces[0]);\n        if (idx >= nodePieces.size()) {\n          throw new SsurgeonParseException(\"SplitWord got an index in -name which was larger than the largest possible split piece, \" + idx + \" (this is 0-indexed)\");\n        }\n        this.nodeNames.put(idx, pieces[1]);\n      }\n    } else {\n      this.nodeNames = Collections.emptyMap();\n    }\n  }\n\n  @Override\n  public String toEditString() {\n    StringWriter buf = new StringWriter();\n    buf.write(LABEL);\n    buf.write(\"\\t\");\n    buf.write(\"-node \" + node + \"\\t\");","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SplitWord.java#L69-L105","documentation":"The optional -name argument of SplitWord assigns semgrex node names to split pieces using the format index=name, comma-separated (e.g. 0=foo,1=bar). Each entry must contain a '=' with a numeric index on the left; otherwise the constructor throws SsurgeonParseException telling you the expected format.","triggerScenarios":"Passing a nodeNames string where any comma-separated entry lacks a '=' or has no numeric index before it, e.g. -name foo,1=bar or -name 0foo.","commonSituations":"Typo in the -name argument (missing '=' or space instead of '='); copy-pasting a name list from another rule with a different format; an extra empty entry from a trailing comma producing a piece without '='.","solutions":["Rewrite the -name argument so every entry is index=name with a 0-based integer index, e.g. -name 0=first,1=second","Remove trailing commas or empty entries from the nodeNames string","Validate the string in your tooling with a regex like ^\\d+=.+(,\\d+=.+)*$ before constructing SplitWord","Also ensure indices are < nodePieces.size(), which is the next check after this one"],"exampleFix":"// before\nnew SplitWord(\"w\", pieces, 0, reln, \"foo,1=bar\", true);\n// after\nnew SplitWord(\"w\", pieces, 0, reln, \"0=foo,1=bar\", true);","handlingStrategy":"validation","validationCode":"if (nodeNames != null && !nodeNames.matches(\"\\\\d+=.+(,\\\\d+=.+)*\")) throw new IllegalArgumentException(\"-name must look like 0=foo,1=bar\");","typeGuard":null,"tryCatchPattern":"try { SplitWord sw = new SplitWord(node, pieces, headIndex, reln, names, exact); } catch (SsurgeonParseException e) { log.error(\"Bad -name format: \" + e.getMessage()); }","preventionTips":["Use the exact index=name, comma-separated format for -name","Strip whitespace and trailing commas from the names string","Validate -name against ^\\d+=.+(,\\d+=.+)*$ before construction and check indices < pieces.size()"],"tags":["ssurgeon","constructor","argument-format"],"backgroundTag":"invalid-argument-format","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"}