stanfordnlp/CoreNLP · error · RuntimeException

Not POS sequence for tree:

Error message

Not POS sequence for tree: 

What it means

Thrown by the same apply method when a Tregex-matched tree contains a child that is not a pre-terminal (POS) node. The POSSequence feature expects the matched node's children to be exactly a sequence of POS-tagged terminals; anything deeper violates the assumed tree shape and aborts annotation.

Solutions

  1. Ensure the input trees are flattened/normalized so MWT matches contain only preterminal children.
  2. Tighten or adjust the Tregex pattern so it only matches flat POS-sequence spans.
  3. Preprocess the treebank with the standard French treebank normalization transforms before annotation.
Defensive patterns

Strategy: try-catch

Try / catch

try { tree = annotator.apply(matcher); } catch (RuntimeException e) { log.warn("Skipping non-flat MWT tree: " + e.getMessage()); }

Prevention

When it happens

Trigger: The Tregex pattern used by the MWT annotation function matches a constituent whose children include non-preterminal subtrees (e.g. nested phrases inside an MWT span) during treebank annotation.

Common situations: Running the French multi-word annotation over a treebank whose trees do not match the flat MWT structure the pattern assumes (different treebank style or partially annotated trees).

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/7444ca01308f0740. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/parser/lexparser/FrenchTreebankParserParams.java:488

    private final boolean doBasicCat;
    private final double cutoff;

    public AddPOSSequenceFunction(String annotationMark, int cutoff, boolean basicCategory) {
      this.annotationMark = annotationMark;
      doBasicCat = basicCategory;
      this.cutoff = cutoff;
    }


    public String apply(TregexMatcher m) {
      if(mwCounter == null)
        throw new RuntimeException("Cannot enable POSSequence features without POS sequence map. Use option -frenchMWMap.");

      Tree t = m.getMatch();
      StringBuilder sb = new StringBuilder();
      for(Tree kid : t.children()) {
        if( ! kid.isPreTerminal())
          throw new RuntimeException("Not POS sequence for tree: " + t.toString());
        String tag = doBasicCat ? tlp.basicCategory(kid.value()) : kid.value();
        sb.append(tag).append(" ");
      }

      if(mwCounter.getCount(t.value(), sb.toString().trim()) > cutoff)
        return annotationMark + sb.toString().replaceAll("\\s+", "").toLowerCase();
      else
        return "";
    }

    @Override
    public String toString() {
      return "AddPOSSequenceFunction[" + annotationMark + ',' + cutoff + ',' + doBasicCat + ']';
    }

    private static final long serialVersionUID = 1L;
  }

View on GitHub (pinned to 1b7edd19c4)