stanfordnlp/CoreNLP · info
%s: Bare tagged word being wrapped in FRAG %s
Error message
%s: Bare tagged word being wrapped in FRAG %s
What it means
A warning from ArabicTreeNormalizer.normalizeWholeTree: if the entire input tree is a single preterminal (a bare tagged word, e.g. '(PUNC .)'), that is 'bad' structure, so for coordination tags (CC), punctuation (PUNC*), or CONJ the normalizer wraps it in a synthetic FRAG node and logs '<class>: Bare tagged word being wrapped in FRAG <pennString>'. Other tags are logged as 'Bare tagged word' without wrapping (a separate message).
Solutions
- Avoid sending single-token trees to the parser/normalizer by filtering one-token segments before parsing
- Accept the FRAG wrapping: output tree remains well-formed for downstream use
- If other bare tags are needed, pre-wrap them yourself in a suitable node before normalization
- Fix upstream sentence splitting so lone punctuation stays attached to adjacent sentences
Example fix
// before
Tree t = parser.apply(word); // word == "." -> whole tree is bare preterminal
normalizer.normalizeWholeTree(t, tf); // warns, wraps in FRAG
// after
if (word.matches("[.?!،؛]+")) return; // skip lone punctuation segments
tree = normalizer.normalizeWholeTree(parser.apply(word), tf); Defensive patterns
Strategy: validation
Validate before calling
// skip single-preterminal trees before parsing/normalizing
if (text.split("\\s+").length <= 1 && text.matches("[.?!،؛]?")) {
return; // or merge with the neighboring sentence
} Try / catch
try {
Tree out = normalizer.normalizeWholeTree(tree, tf);
if (out.isPreTerminal()) log.warn("Tree is still a bare preterminal after normalization");
} catch (Exception e) {
log.warn("Normalization failed", e);
} Prevention
- Improve sentence splitting so lone punctuation/conjunctions never form their own segment
- Post-check that parser output trees are not single preterminals
- For one-word fragments of content words, wrap in (FRAG ...) yourself before processing
When it happens
Trigger: Calling normalizeWholeTree on a tree consisting of exactly one preterminal — typically when sentence segmentation fed a single token (a lone period, conjunction, or particle) to the parser/normalizer.
Common situations: Tokenizing/splitting text that yields one-word 'sentences' (standalone punctuation, 'و' conjunction); parsing sentence fragments from Arabic text then normalizing them for training data.
Related errors
- %s: missing tag for %s
- %s: Splicing in DUMMYTAG for %s
- this.getClass().getName() + ": Case is presently unsupported
- Arabic does not support feature type: " + feat.toString()
- : Parser grammar does not exist
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/1df3f127e4d1d83a.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/trees/international/arabic/ArabicTreeNormalizer.java:217
prd.label().setValue(super.normalizeNonterminal(prd.label().value()));
}
}
}
//Mark *only* subjects in verb-initial clauses
if(retainNPSbj) {
TregexMatcher m = npSbjPattern.matcher(tree);
while (m.find()) {
Tree match = m.getMatch();
match.label().setValue("NP");
}
}
if (tree.isPreTerminal()) {
// The whole tree is a bare tag: bad!
String val = tree.label().value();
if (val.equals("CC") || val.startsWith("PUNC") || val.equals("CONJ")) {
log.warn(String.format("%s: Bare tagged word being wrapped in FRAG %s", this.getClass().getName(),tree.pennString()));
tree = tf.newTreeNode("FRAG", Collections.singletonList(tree));
} else {
log.warn(String.format("%s: Bare tagged word %s", this.getClass().getName(), tree.pennString()));
}
}
//Add start symbol so that the root has only one sub-state. Escape any enclosing brackets.
//If the "tree" consists entirely of enclosing brackets e.g. ((())) then this method
//will return null. In this case, readers e.g. PennTreeReader will try to read the next tree.
while (tree != null && (tree.value() == null || tree.value().isEmpty()) && tree.numChildren() <= 1) {
tree = tree.firstChild();
}
if (tree != null && !tree.value().equals(rootLabel)) {
tree = tf.newTreeNode(rootLabel, Collections.singletonList(tree));
}
return tree;View on GitHub (pinned to 1b7edd19c4)