stanfordnlp/CoreNLP · error · RuntimeException
: Term lacks morpho analysis
Error message
%s: Term lacks morpho analysis: %s
What it means
transformTree adds morphosyntactic features to POS tags, but only if the terminal's label is a CoreLabel carrying a non-null originalText holding the morpho analysis string (lemma+morph separated by the morph separator). If the tag spec is active yet the leaf lacks that analysis, the parser cannot derive features and throws with the offending tree.
Solutions
- Run the morpho annotation pass (MorphoTreeTransformer with -morphoFile) on the trees before transformTree.
- Ensure leaves are CoreLabels that preserve originalText (label annotations must not be stripped).
- Disable the morpho feature option (tagSpec) if no morphological analysis is available.
Example fix
// before LexicalizedParser.parseTrees(op.tlpParams, trees) // trees lack morpho annotation // after MorphoTreeTransformer mt = new MorphoTreeTransformer(morphSpec); List<Tree> annotated = trees.stream().map(mt::transformTree).collect(Collectors.toList());
Defensive patterns
Strategy: validation
Validate before calling
for (Tree t : trees) {
for (Tree leaf : t.getLeaves()) {
if (!(leaf.label() instanceof CoreLabel) || ((CoreLabel) leaf.label()).originalText() == null)
throw new IllegalStateException("Leaf lacks morpho analysis: " + leaf);
}
} Try / catch
try { tree = params.transformTree(tree); } catch (RuntimeException e) { log.error(e.getMessage()); throw e; } Prevention
- Run the MorphoTreeTransformer (-morphoFile) before training/parsing with morpho features
- Use CoreLabel factories so originalText survives preprocessing
When it happens
Trigger: Parsing/training with -tagPairedMorphoFeatures (or equivalent tagSpec) while the input trees' terminals were not annotated with morpho strings via a MorphoTreeTransformer / -morphoFile preprocessing step.
Common situations: Feeding raw French treebank trees to a morphologically annotated model, or forgetting the morpho annotation pass so originalText is null on the leaves.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- French does not support feature type:
- Cannot enable POSSequence features without POS sequence…
- Not POS sequence for tree:
- No gold info
- ERROR: Relation extraction requires full syntactic analysis!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c5c1c57476f39391.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/parser/lexparser/FrenchTreebankParserParams.java:590
return (readPennFormat) ? new FrenchTreeReaderFactory() : new FrenchXMLTreeReaderFactory(false);
}
public List<HasWord> defaultTestSentence() {
String[] sent = {"Ceci", "est", "seulement", "un", "test", "."};
return SentenceUtils.toWordList(sent);
}
@Override
public Tree transformTree(Tree t, Tree root) {
// Perform tregex-powered annotations
t = super.transformTree(t, root);
String cat = t.value();
//Add morphosyntactic features if this is a POS tag
if(t.isPreTerminal() && tagSpec != null) {
if( !(t.firstChild().label() instanceof CoreLabel) || ((CoreLabel) t.firstChild().label()).originalText() == null )
throw new RuntimeException(String.format("%s: Term lacks morpho analysis: %s",this.getClass().getName(),t.toString()));
String morphoStr = ((CoreLabel) t.firstChild().label()).originalText();
Pair<String,String> lemmaMorph = MorphoFeatureSpecification.splitMorphString("", morphoStr);
MorphoFeatures feats = tagSpec.strToFeatures(lemmaMorph.second());
cat = feats.getTag(cat);
}
//Update the label(s)
t.setValue(cat);
if (t.isPreTerminal() && t.label() instanceof HasTag)
((HasTag) t.label()).setTag(cat);
return t;
}
private void loadMWMap(String filename) {
mwCounter = new TwoDimensionalCounter<>();View on GitHub (pinned to 1b7edd19c4)