stanfordnlp/CoreNLP · error · RuntimeException

edge cliqueFeatures[n]=

Error message

edge cliqueFeatures[n]=

What it means

The edge-case counterpart of error 207: for cliques with j>0 (edge cliques), transformDocData looks up cliqueFeatures[n] in edgeFeatureIndicesMap and throws RuntimeException('edge cliqueFeatures[n]=... not found, edgeFeatureIndicesMap.size=...') when the feature index is missing. The edge feature space does not contain a feature observed in the data being transformed.

Solutions

  1. Rebuild edgeFeatureIndicesMap by extracting edge features across all training documents before transforming data.
  2. Confirm identical featureFactory/feature semantics flags between the indexing pass and document conversion.
  3. Re-run index construction after any change to training data or feature configuration.
  4. Ensure documents passed to documentToDataAndLabels come from the same preprocessing pipeline used to build the index maps.
  5. Add diagnostics (log the missing feature index) to find which clique/factory generates the unregistered feature.

Example fix

// before
// edge index map built with useSum = false, later documents extracted with useSum = true -> features diverge
props.setProperty("useSum", "false"); buildMaps(); props.setProperty("useSum", "true"); transform();
// after
props.setProperty("useSum", "true");
buildMaps();          // same flags for indexing
transform();          // same flags for transformation
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

try {
  int[][][][] trans = transformDocData(docData);
} catch (RuntimeException e) {
  if (String.valueOf(e.getMessage()).startsWith("edge cliqueFeatures"))
    throw new IllegalStateException("Edge feature index map incomplete — rebuild edge index maps from all training documents", e);
  throw e;
}

Prevention

When it happens

Trigger: During documentToDataAndLabels -> transformDocData, when an edge-clique feature index is absent from edgeFeatureIndicesMap — typically because edge feature extraction during index-map construction did not cover the features later seen in the documents.

Common situations: Nonlinear CRF training with mismatched feature factory settings between indexing and transformation; documents containing features unseen during index building; reused/stale edge index maps; mixed dataset preprocessing.

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/d217dea93a7f2f23. Report an issue: GitHub.

Appendix: source

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

  }

  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
        cliquePotentialFunction = new NonLinearCliquePotentialFunction(linearWeights, inputLayerWeights, outputLayerWeights, flags);
    }
    return cliquePotentialFunction;
  }

View on GitHub (pinned to 1b7edd19c4)