{"record":{"id":"cc705d4300084d76","repo":"stanfordnlp/CoreNLP","slug":"s-word-contains-malformed-morph-annotation-s","errorCode":null,"errorMessage":"%s: Word contains malformed morph annotation: %s","messagePattern":"(.+?): Word contains malformed morph annotation: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/international/arabic/ArabicTreeNormalizer.java","lineNumber":133,"sourceCode":"      normalizedString = super.normalizeNonterminal(category);\n    }\n\n    return normalizedString.intern();\n  }\n\n  @Override\n  public Tree normalizeWholeTree(Tree tree, TreeFactory tf) {\n    tree = tree.prune(emptyFilter, tf).spliceOut(aOverAFilter, tf);\n\n    for (Tree t : tree) {\n\n      if(t.isLeaf()) {\n        //Strip off morphological analyses and place them in the OriginalTextAnnotation, which is\n        //specified by HasContext.\n        if(t.value().contains(MorphoFeatureSpecification.MORPHO_MARK)) {\n          String[] toks = t.value().split(MorphoFeatureSpecification.MORPHO_MARK);\n          if (toks.length != 2) {\n            log.err(String.format(\"%s: Word contains malformed morph annotation: %s\", this.getClass().getName(), t.value()));\n          } else if (t.label() instanceof CoreLabel) {\n            CoreLabel cl = (CoreLabel) t.label();\n            cl.setValue(toks[0].trim().intern());\n            cl.setWord(toks[0].trim().intern());\n\n            Pair<String,String> lemmaMorph = MorphoFeatureSpecification.splitMorphString(toks[0], toks[1]);\n            String lemma = lemmaMorph.first();\n            String morphAnalysis = lemmaMorph.second();\n            if (lemma.equals(toks[0])) {\n              cl.setOriginalText(toks[1].trim().intern());\n            } else {\n              // TODO(spenceg): Does this help?\n              String newLemma = lexMapper.map(null, lemma);\n              if (newLemma == null || newLemma.trim().isEmpty()) {\n                newLemma = lemma;\n              }\n              String newMorphAnalysis = newLemma + MorphoFeatureSpecification.LEMMA_MARK + morphAnalysis;\n              cl.setOriginalText(newMorphAnalysis.intern());","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/international/arabic/ArabicTreeNormalizer.java#L115-L151","documentation":"ArabicTreeNormalizer.normalizeWholeTree strips morphological analyses appended to leaf values with the MORPHO_MARK separator. If a leaf splits into other than exactly two parts, the tree value is malformed and the normalizer logs this error and leaves the leaf unchanged rather than crashing.","triggerScenarios":"Normalizing an Arabic tree whose leaf value contains the morpho mark character but not exactly one occurrence separating word and morph features (e.g. 'word\tmorphA\tmorphB' or a stray mark with nothing after it).","commonSituations":"Preprocessed Arabic treebanks where the separator character appears inside the word itself; hand-edited trees; double-morph-annotation from running a pipeline twice.","solutions":["Inspect the offending leaf value printed in the message and remove duplicate/stray morph mark characters","Ensure each annotated leaf has the form word + morphoMark + morphFeatures with no extra marks","Re-export or re-clean the treebank file; re-run annotation from the raw source","If intentional multi-part values are needed, pre-split them before normalization"],"exampleFix":"// before (leaf value)\n\"word\tNAUF\tdef\tnom\"\n// after\n\"word\tNAUF def nom\"  // exactly one MORPHO_MARK separating word and features","handlingStrategy":"validation","validationCode":"String v = leaf.value();\nif (v != null && v.contains(MorphoFeatureSpecification.MORPHO_MARK)) {\n  String[] toks = v.split(MorphoFeatureSpecification.MORPHO_MARK);\n  if (toks.length != 2) throw new IllegalArgumentException(\"bad morph annotation: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n  tree = normalizer.normalizeWholeTree(tree, treeFactory);\n} catch (Exception e) {\n  log.warn(\"skipping malformed tree: \" + e.getMessage());\n}","preventionTips":["Keep exactly one MORPHO_MARK separator per annotated leaf","Sanitize treebank files so the separator never appears inside words","Never run morph annotation twice on the same tree","Validate a sample of the treebank before full normalization"],"tags":["java","nlp","arabic","parsing"],"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"}