stanfordnlp/CoreNLP · error · IllegalArgumentException

Unknown clique: " + clique

Error message

Unknown clique: " + clique

What it means

NERFeatureFactory.getCliqueFeatures dispatches on the requested clique (C, CpC, CpCp2C, etc.) and throws IllegalArgumentException when the clique identifier does not match any supported template. This guards the feature extraction against unknown clique constants passed in during training or inference.

Solutions

  1. Use only clique constants defined in NERFeatureFactory (cliqueC, cliqueCpC, cliqueCp2C, cliqueCpCp2C, cliqueCpCp2Cp3C, etc.).
  2. Inspect the flags (featureFactory and clique settings) to ensure the selected factory supports the configured cliques.
  3. If a custom clique is needed, extend NERFeatureFactory and add a branch plus the corresponding feature extraction method.

Example fix

// before
flags.featureFactory = new NERFeatureFactory();
cliques.add(myCustomClique); // unknown clique
// after
flags.featureFactory = new NERFeatureFactory();
cliques.add(Clique.valueOf(new String[]{"C","pC"})); // supported clique
Defensive patterns

Strategy: validation

Validate before calling

Set<Clique> allowed = NERFeatureFactory.cliques; // all cliques defined by NERFeatureFactory
if (!allowed.contains(clique)) {
  throw new IllegalArgumentException("Clique not supported by NERFeatureFactory: " + clique);
}

Try / catch

try {
  List<String> feats = featureFactory.getCliqueFeatures(p, pos, clique);
} catch (IllegalArgumentException e) {
  throw new IllegalStateException("Unsupported clique config for NER: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Passing a clique Clique/Factor value to getCliqueFeatures that is not one of the constants defined in NERFeatureFactory (e.g. a clique from a different feature factory or a custom clique), typically via a flags/clique config in SeqClassifierFlags.

Common situations: Mixing CRFFeatureFactory cliques with NERFeatureFactory, custom flag edits adding unsupported cliques, or upgrading models trained with cliques unsupported by this factory.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/ie/NERFeatureFactory.java:431

      featuresCpC(cInfo, loc, c);
      featuresCnC(cInfo, loc - 1, c);
    } else if (clique == cliqueCp2C) {
      featuresCp2C(cInfo, loc, c);
    } else if (clique == cliqueCp3C) {
      featuresCp3C(cInfo, loc, c);
    } else if (clique == cliqueCp4C) {
      featuresCp4C(cInfo, loc, c);
    } else if (clique == cliqueCp5C) {
      featuresCp5C(cInfo, loc, c);
    } else if (clique == cliqueCpCp2C) {
      featuresCpCp2C(cInfo, loc, c);
      featuresCpCnC(cInfo, loc - 1, c);
    } else if (clique == cliqueCpCp2Cp3C) {
      featuresCpCp2Cp3C(cInfo, loc, c);
    } else if (clique == cliqueCpCp2Cp3Cp4C) {
      featuresCpCp2Cp3Cp4C(cInfo, loc, c);
    } else {
      throw new IllegalArgumentException("Unknown clique: " + clique);
    }

    // log.info(StringUtils.join(features,"\n")+"\n");
    return features;
  }

  /**
   * This class handles collecting features into a set, in a more memory efficient way.
   *
   * The benefits arise from handling the concatenation and suffix appending re-using a
   * single buffer, rather than repeatedly concatenating strings.
   *
   * This class is <em>not thread safe</em>, but you are unlikely to want to parallelize
   * at this low level anyway.
   *
   * @author Erich Schubert
   */
  protected static class FeatureCollector {

View on GitHub (pinned to 1b7edd19c4)