{"record":{"id":"d217dea93a7f2f23","repo":"stanfordnlp/CoreNLP","slug":"edge-cliquefeatures-n","errorCode":null,"errorMessage":"edge cliqueFeatures[n]=","messagePattern":"edge cliqueFeatures\\[n\\]=","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifierNonlinear.java","lineNumber":93,"sourceCode":"  }\n\n  private int[][][] transformDocData(int[][][] docData) {\n    int[][][] transData = new int[docData.length][][];\n    for (int i = 0; i < docData.length; i++) {\n      transData[i] = new int[docData[i].length][];\n      for (int j = 0; j < docData[i].length; j++) {\n        int[] cliqueFeatures = docData[i][j];\n        transData[i][j] = new int[cliqueFeatures.length];\n        for (int n = 0; n < cliqueFeatures.length; n++) {\n          int transFeatureIndex = -1;\n          if (j == 0) {\n            transFeatureIndex = nodeFeatureIndicesMap.indexOf(cliqueFeatures[n]);\n            if (transFeatureIndex == -1)\n              throw new RuntimeException(\"node cliqueFeatures[n]=\"+cliqueFeatures[n]+\" not found, nodeFeatureIndicesMap.size=\"+nodeFeatureIndicesMap.size());\n          } else {\n            transFeatureIndex = edgeFeatureIndicesMap.indexOf(cliqueFeatures[n]);\n            if (transFeatureIndex == -1)\n              throw new RuntimeException(\"edge cliqueFeatures[n]=\"+cliqueFeatures[n]+\" not found, edgeFeatureIndicesMap.size=\"+edgeFeatureIndicesMap.size());\n          }\n          transData[i][j][n] = transFeatureIndex;\n        }\n      }\n    }\n    return transData;\n  }\n\n  @Override\n  protected CliquePotentialFunction getCliquePotentialFunctionForTest() {\n    if (cliquePotentialFunction == null) {\n      if (flags.secondOrderNonLinear)\n        cliquePotentialFunction = new NonLinearSecondOrderCliquePotentialFunction(inputLayerWeights4Edge, outputLayerWeights4Edge, inputLayerWeights, outputLayerWeights, flags);\n      else\n        cliquePotentialFunction = new NonLinearCliquePotentialFunction(linearWeights, inputLayerWeights, outputLayerWeights, flags);\n    }\n    return cliquePotentialFunction;\n  }","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifierNonlinear.java#L75-L111","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rebuild edgeFeatureIndicesMap by extracting edge features across all training documents before transforming data.","Confirm identical featureFactory/feature semantics flags between the indexing pass and document conversion.","Re-run index construction after any change to training data or feature configuration.","Ensure documents passed to documentToDataAndLabels come from the same preprocessing pipeline used to build the index maps.","Add diagnostics (log the missing feature index) to find which clique/factory generates the unregistered feature."],"exampleFix":"// before\n// edge index map built with useSum = false, later documents extracted with useSum = true -> features diverge\nprops.setProperty(\"useSum\", \"false\"); buildMaps(); props.setProperty(\"useSum\", \"true\"); transform();\n// after\nprops.setProperty(\"useSum\", \"true\");\nbuildMaps();          // same flags for indexing\ntransform();          // same flags for transformation","handlingStrategy":"validation","validationCode":"for (int[][] doc : data) {\n  for (int[] cliqueFeatures : doc) {\n    for (int fi : cliqueFeatures)\n      if (fi >= 0 && edgeFeatureIndicesMap.indexOf(fi) == -1)\n        throw new IllegalStateException(\"Edge feature \" + fi + \" missing from edgeFeatureIndicesMap (size=\" + edgeFeatureIndicesMap.size() + \")\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  int[][][][] trans = transformDocData(docData);\n} catch (RuntimeException e) {\n  if (String.valueOf(e.getMessage()).startsWith(\"edge cliqueFeatures\"))\n    throw new IllegalStateException(\"Edge feature index map incomplete — rebuild edge index maps from all training documents\", e);\n  throw e;\n}","preventionTips":["Extract edge features across all documents when constructing edgeFeatureIndicesMap.","Keep feature extraction flags identical between indexing and transformation passes.","Regenerate index maps after any data or feature-config change.","Log the missing feature index to identify the offending feature factory."],"tags":["java","crf","feature-index","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}