{"record":{"id":"cddcbfbfa17661a5","repo":"stanfordnlp/CoreNLP","slug":"s-term-lacks-morpho-analysis-s","errorCode":null,"errorMessage":"%s: Term lacks morpho analysis: %s","messagePattern":"(.+?): Term lacks morpho analysis: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/ArabicTreebankParserParams.java","lineNumber":250,"sourceCode":"  \n  @Override\n  public Tree transformTree(Tree t, Tree root) {\n\n    String baseCat = t.value();\n    StringBuilder newCategory = new StringBuilder();\n\n    //Add manual state splits\n    for (Pair<TregexPattern,Function<TregexMatcher,String>> e : activeAnnotations) {\n      TregexMatcher m = e.first().matcher(root);\n      if (m.matchesAt(t))\n        newCategory.append(e.second().apply(m));\n    }\n\n    // WSGDEBUG\n    //Add morphosyntactic features if this is a POS tag\n    if(t.isPreTerminal() && tagSpec != null) {\n      if( !(t.firstChild().label() instanceof CoreLabel) || ((CoreLabel) t.firstChild().label()).originalText() == null )\n        throw new RuntimeException(String.format(\"%s: Term lacks morpho analysis: %s\",this.getClass().getName(),t.toString()));\n\n      String morphoStr = ((CoreLabel) t.firstChild().label()).originalText();\n      MorphoFeatures feats = tagSpec.strToFeatures(morphoStr);\n      baseCat = feats.getTag(baseCat);\n    }\n\n    //Update the label(s)\n    String newCat = baseCat + newCategory;\n    t.setValue(newCat);\n    if (t.isPreTerminal() && t.label() instanceof HasTag)\n      ((HasTag) t.label()).setTag(newCat);\n\n    return t;\n  }\n\n  /**\n   * These are the annotations included when the user selects the -arabicFactored option.\n   */","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ArabicTreebankParserParams.java#L232-L268","documentation":"When the Arabic treebank params apply tag-level morphosyntactic features, it requires each pre-terminal's leaf label to be a CoreLabel carrying a non-null originalText() that encodes the morphological analysis (tag Spec). If the label is not a CoreLabel or originalText() is null, the tree lacks the morpho analysis the tagSpec expects, so a RuntimeException with the class name and tree is thrown.","triggerScenarios":"Parsing/transforming Arabic trees with morphological tagging enabled (uncaught tagSpec) while the input trees were read with default LabeledScoredTreeReaderFactory so leaves are not CoreLabels, or the reader did not set originalText from the gold morpho analysis column.","commonSituations":"Training/evaluating the Arabic parser where tree files were loaded without the Arabic custom tree reader that parses the morphological analyses; using tree output from another tool that strips the 'morpho' annotation.","solutions":["Load trees with the Arabic-specific tree reader factory that produces CoreLabels with originalText set to the morphological analysis","Verify the input treebank lines contain the morpho analyses (the tab-separated analyses field)","Disable the morphological-feature option if your trees have no morpho analysis"],"exampleFix":"// before\nTreeReaderFactory trf = new LabeledScoredTreeReaderFactory();\n// after (use the Arabic params' default reader)\nTreeReaderFactory trf = params.treeReaderFactory(); // ArabicTreebankParserParams -> ArabicTreeReaderFactory with morpho analyses","handlingStrategy":"validation","validationCode":"// before transformTree, check each pre-terminal leaf\nfor (Tree t : tree.preTerminals()) {\n  if (!(t.firstChild().label() instanceof CoreLabel)\n      || ((CoreLabel) t.firstChild().label()).originalText() == null) {\n    throw new IllegalArgumentException(\"Tree lacks morpho analysis at: \" + t);\n  }\n}","typeGuard":"function hasMorphoAnalysis(t) {\n  return t.isPreTerminal() && t.firstChild().label() instanceof CoreLabel\n      && ((CoreLabel) t.firstChild().label()).originalText() != null;\n}","tryCatchPattern":"try {\n  Tree transformed = params.transformTree(t);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"Term lacks morpho analysis\")) {\n    log.severe(\"Input trees missing Arabic morpho analyses; reload with Arabic tree reader\");\n  }\n  throw e;\n}","preventionTips":["Load Arabic trees with ArabicTreebankParserParams' own tree reader factory","Confirm treebank input lines include the morphological analysis column","Disable morphological features when using trees from external tools"],"tags":["java","stanford-parser","arabic","missing-data","treebank"],"backgroundTag":"missing-required-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}