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

  1. Avoid sending single-token trees to the parser/normalizer by filtering one-token segments before parsing
  2. Accept the FRAG wrapping: output tree remains well-formed for downstream use
  3. If other bare tags are needed, pre-wrap them yourself in a suitable node before normalization
  4. 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

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


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)