stanfordnlp/CoreNLP · error · ParseException

Unknown multi relation

Error message

Unknown multi relation ${s}

What it means

Relation.constructMultiRelation() builds composite patterns for multi relations (like <<, <<1) by expanding them into conjunctions of simpler relations; a symbol not recognized as a multi relation throws ParseException. It means the query used a multi-child relation the builder cannot expand.

Solutions

  1. Use a supported multi relation symbol (e.g. <<, <<1 style indexed forms) in the query
  2. Check the constructMultiRelation source/switch for the exact symbols handled in your version
  3. Fix typos in the multi-operator prefix (extra/missing angle brackets)
  4. Upgrade CoreNLP if the query relies on a multi relation your version lacks

Example fix

// before
String q = "A <<> B"; // unknown multi relation
// after
String q = "A << B"; // supported multi relation
Defensive patterns

Strategy: try-catch

Validate before calling

Set<String> multiRels = Set.of("<<", "<<1", "<<'", "<<'"); // per-version whitelist
if (!multiRels.contains(s)) throw new IllegalArgumentException("Unknown multi relation: " + s);

Try / catch

try {
  Relation.constructMultiRelation(s, basicCatFunction, headFinder, children);
} catch (ParseException e) {
  throw new TregexQueryException("Unsupported multi relation '" + s + "'", e);
}

Prevention

When it happens

Trigger: Calling constructMultiRelation with a symbol outside the supported multi-relation set (e.g. a typo like '<<>' or an operator from a newer/older CoreNLP), typically reached while parsing a tregex query.

Common situations: Hand-written tregex queries with malformed multi operators; version drift where a multi relation was added or renamed; programmatic query builders emitting wrong symbols.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/trees/tregex/Relation.java:193

   */
  static TregexPattern constructMultiRelation(String s, List<DescriptionPattern> children,
                                              Function<String, String> basicCatFunction,
                                              HeadFinder headFinder) throws ParseException {
    if (s.equals("<...")) {
      List<TregexPattern> newChildren = Generics.newArrayList();
      for (int i = 0; i < children.size(); ++i) {
        Relation rel = getRelation("<", Integer.toString(i + 1), basicCatFunction, headFinder); 
        DescriptionPattern oldChild = children.get(i);
        TregexPattern newChild = new DescriptionPattern(rel, oldChild);
        newChildren.add(newChild);
      }
      Relation rel = getRelation("<", Integer.toString(children.size() + 1), basicCatFunction, headFinder);
      TregexPattern noExtraChildren = new DescriptionPattern(rel, false, "__", null, false, basicCatFunction, Collections.<Pair<Integer,String>>emptyList(), false, null);
      noExtraChildren.negate();
      newChildren.add(noExtraChildren);
      return new CoordinationPattern(newChildren, true);
    } else {
      throw new ParseException("Unknown multi relation " + s);
    }
  }

  private Relation(String symbol) {
    this.symbol = symbol;
  }

  @Override
  public String toString() {
    return symbol;
  }

  /**
   * This abstract Iterator implements a NULL iterator, but by subclassing and
   * overriding advance and/or initialize, it is an efficient implementation.
   */
  abstract static class SearchNodeIterator implements Iterator<Tree> {
    public SearchNodeIterator() {

View on GitHub (pinned to 1b7edd19c4)