stanfordnlp/CoreNLP · error · RuntimeException

node cliqueFeatures[n]=

Error message

node cliqueFeatures[n]=

What it means

CRFClassifierNonlinear.transformDocData remaps each clique's feature indices into either the node or edge feature index map depending on the clique type j==0 (node) or j>0 (edge). If cliqueFeatures[n] is not present in nodeFeatureIndicesMap, it throws RuntimeException('node cliqueFeatures[n]=... not found, nodeFeatureIndicesMap.size=...'), an invariant violation meaning the feature index was never registered in the node feature space.

Solutions

  1. Ensure feature index maps (nodeFeatureIndicesMap) are built by running feature extraction over the full training data before transformDocData.
  2. Verify the same FeatureFactory configuration is used for both index-map construction and document conversion.
  3. Clear stale cached index maps / re-run the index-building pass if data changed.
  4. Check that the document data being transformed came from the same corpus/label scheme used to build the maps.
  5. Log the missing feature to identify which feature factory produces it and why it was unregistered.

Example fix

// before
// index maps built from only the first document
int[][][] docData = docDatas.get(0);
buildFeatureIndexMap(docData); // incomplete
// after
// build maps from ALL documents before transforming any
for (int[][][] d : docDatas) addToFeatureIndexMap(d);
buildFeatureIndexMap();
int[][][][] trans = transformDocData(docData);
Defensive patterns

Strategy: validation

Validate before calling

for (int[][] doc : data) {
  for (int[] cliqueFeatures : doc) {
    for (int fi : cliqueFeatures)
      if (fi >= 0 && nodeFeatureIndicesMap.indexOf(fi) == -1)
        throw new IllegalStateException("Node feature " + fi + " missing from nodeFeatureIndicesMap (size=" + nodeFeatureIndicesMap.size() + ")");
  }
}

Try / catch

try {
  int[][][][] trans = transformDocData(docData);
} catch (RuntimeException e) {
  if (String.valueOf(e.getMessage()).startsWith("node cliqueFeatures"))
    throw new IllegalStateException("Feature index maps were not built from this training data — rebuild index maps before transforming", e);
  throw e;
}

Prevention

When it happens

Trigger: During documentToDataAndLabels -> transformDocData, when a feature index appearing in the document data's node cliques (j==0) is absent from nodeFeatureIndicesMap — e.g. feature maps built from different data, index maps not initialized from training data, or mismatched feature factories between weight-building and data-transformation passes.

Common situations: Training nonlinear CRF where the node feature index map was built from a subset of documents; custom feature factory producing features after index maps were frozen; stale/cached index maps reused across datasets; version mismatch in pipeline components.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/edu/stanford/nlp/ie/crf/CRFClassifierNonlinear.java:89

    int[][][] data = result.first();
    data = transformDocData(data);

    return new Triple<>(data, result.second(), result.third());
  }

  private int[][][] transformDocData(int[][][] docData) {
    int[][][] transData = new int[docData.length][][];
    for (int i = 0; i < docData.length; i++) {
      transData[i] = new int[docData[i].length][];
      for (int j = 0; j < docData[i].length; j++) {
        int[] cliqueFeatures = docData[i][j];
        transData[i][j] = new int[cliqueFeatures.length];
        for (int n = 0; n < cliqueFeatures.length; n++) {
          int transFeatureIndex = -1;
          if (j == 0) {
            transFeatureIndex = nodeFeatureIndicesMap.indexOf(cliqueFeatures[n]);
            if (transFeatureIndex == -1)
              throw new RuntimeException("node cliqueFeatures[n]="+cliqueFeatures[n]+" not found, nodeFeatureIndicesMap.size="+nodeFeatureIndicesMap.size());
          } else {
            transFeatureIndex = edgeFeatureIndicesMap.indexOf(cliqueFeatures[n]);
            if (transFeatureIndex == -1)
              throw new RuntimeException("edge cliqueFeatures[n]="+cliqueFeatures[n]+" not found, edgeFeatureIndicesMap.size="+edgeFeatureIndicesMap.size());
          }
          transData[i][j][n] = transFeatureIndex;
        }
      }
    }
    return transData;
  }

  @Override
  protected CliquePotentialFunction getCliquePotentialFunctionForTest() {
    if (cliquePotentialFunction == null) {
      if (flags.secondOrderNonLinear)
        cliquePotentialFunction = new NonLinearSecondOrderCliquePotentialFunction(inputLayerWeights4Edge, outputLayerWeights4Edge, inputLayerWeights, outputLayerWeights, flags);
      else

View on GitHub (pinned to 1b7edd19c4)