{"record":{"id":"050719020c1d4507","repo":"stanfordnlp/CoreNLP","slug":"cannot-make-a-lemmatize-with-no-nodename","errorCode":null,"errorMessage":"Cannot make a Lemmatize with no nodeName","messagePattern":"Cannot make a Lemmatize with no nodeName","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Lemmatize.java","lineNumber":29,"sourceCode":"\n/**\n * Add the output of the English lemmatizer to the word in question.\n * Currently this only supports English!  You can add a known lemma\n * for a different language by using EditNode and setting the lemma\n * attribute\n *\n * @author John Bauer\n */\npublic class Lemmatize extends SsurgeonEdit {\n  public static final String LABEL = \"lemmatize\";\n\n  final String nodeName;\n  final Morphology morphology;\n  final Language language;\n\n  public Lemmatize(String nodeName, Language language) {\n    if (nodeName == null) {\n      throw new SsurgeonParseException(\"Cannot make a Lemmatize with no nodeName\");\n    }\n    this.nodeName = nodeName;\n\n    if (language == Language.UniversalEnglish || language == Language.English) {\n      this.language = Language.English;\n    } else if (language == Language.Unknown) {\n      // log something here?\n      this.language = Language.English;\n    } else {\n      throw new SsurgeonParseException(\"Lemmatizing \" + language + \" is not supported\");\n    }\n\n    this.morphology = new Morphology();\n  }\n\n  @Override\n  public String toEditString() {\n    StringBuilder buf = new StringBuilder();","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Lemmatize.java#L11-L47","documentation":"Lemmatize re-lemmatizes the word of a matched node, so it requires the name of a node in the semgrex match. Constructing it with a null nodeName throws SsurgeonParseException. English variants are normalized to Language.English; Unknown falls back per the constructor logic.","triggerScenarios":"new Lemmatize(null, language) — e.g. an Ssurgeon lemmatize instruction missing its -node argument, or code passing a variable that was never assigned a matched node name.","commonSituations":"Hand-written .ssurgeon rules with the node argument dropped; automated rule generation where match-group names come back null.","solutions":["Pass the name of a node from the semgrex pattern as nodeName.","Ensure the -node argument is present in the lemmatize instruction in the rule file.","Add a null/empty check before constructing Lemmatize and report the rule name for easier debugging."],"exampleFix":"// before\nnew Lemmatize(null, Language.UniversalEnglish);\n\n// after\nnew Lemmatize(\"word\", Language.UniversalEnglish); // \"word\" is a node in the pattern","handlingStrategy":"validation","validationCode":"// Java\nif (nodeName == null || nodeName.isBlank()) {\n  throw new IllegalArgumentException(\"lemmatize requires a -node argument naming a matched node\");\n}","typeGuard":"// Java\nstatic boolean hasNodeName(String nodeName) {\n  return nodeName != null && !nodeName.isBlank();\n}","tryCatchPattern":"// Java\ntry {\n  Lemmatize op = new Lemmatize(nodeName, language);\n} catch (SsurgeonParseException e) {\n  log.severe(\"Invalid lemmatize rule: \" + e.getMessage());\n}","preventionTips":["Ensure every lemmatize instruction in .ssurgeon files carries a -node argument.","Confirm the node name matches a node captured by the semgrex pattern."],"tags":["java","ssurgeon","null-check","validation"],"backgroundTag":"null-argument","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"}