stanfordnlp/CoreNLP · error · IllegalArgumentException
Invalid hypGraph
Error message
Invalid hypGraph
What it means
Alignment.makeFromIndexArray throws IllegalArgumentException("Invalid hypGraph " + hypGraph) when the hypothesis SemanticGraph is null or empty. The index array is sized against the hyp graph, so an empty/null hyp graph makes the alignment undefined.
Solutions
- Verify hypGraph != null && hypGraph.size() > 0 before the call
- Also ensure indexes.length equals hypGraph.size() (the next precondition checked)
- Filter out empty hypothesis graphs earlier in the pipeline
Example fix
// before
Alignment a = Alignment.makeFromIndexArray(txtGraph, hypGraph, idx, 1.0, "j");
// after
if (hypGraph != null && hypGraph.size() > 0 && idx.length == hypGraph.size()) {
Alignment a = Alignment.makeFromIndexArray(txtGraph, hypGraph, idx, 1.0, "j");
} Defensive patterns
Strategy: validation
Validate before calling
if (hypGraph != null && hypGraph.size() > 0 && indexes != null && indexes.length == hypGraph.size()) { Alignment a = Alignment.makeFromIndexArray(txtGraph, hypGraph, indexes, score, just); } Type guard
boolean validHyp = h != null && !h.isEmpty() && indexes != null && indexes.length == h.size();
Try / catch
try { a = Alignment.makeFromIndexArray(txt, hyp, idx, score, just); } catch (IllegalArgumentException e) { log.warn("Alignment skipped: " + e.getMessage()); } Prevention
- Check hyp graph population before indexing against it
- Keep indexes array length synced to hypGraph.size()
- Filter empty hypothesis sentences earlier in the pipeline
When it happens
Trigger: Calling makeFromIndexArray with hypGraph == null or a zero-vertex SemanticGraph, typically from an empty hypothesis sentence parse.
Common situations: Entailment/RTE pipelines feeding unpopulated hypothesis graphs after failed parsing; null propagation through match/alignment chains.
Related errors
- Invalid txtGraph
- conditionalLogProbGivenPrevious requires given one less…
- conditionalLogProbsGivenPrevious requires given one less…
- conditionalLogProbGivenFirst requires of one less than…
- unnormalizedConditionalLogProbGivenFirst requires of one…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/36045ef6e557f908.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/Alignment.java:162
/**
* Constructs and returns a new Alignment from the given hypothesis
* {@code SemanticGraph} to the given text (passage) SemanticGraph, using
* the given array of indexes. The i'th node of the array should contain the
* index of the node in the text (passage) SemanticGraph to which the i'th
* node in the hypothesis SemanticGraph is aligned, or -1 if it is aligned to
* NO_WORD.
*/
public static Alignment makeFromIndexArray(SemanticGraph txtGraph,
SemanticGraph hypGraph,
int[] indexes,
double score,
String justification) {
if (txtGraph == null || txtGraph.isEmpty())
throw new IllegalArgumentException("Invalid txtGraph " + txtGraph);
if (hypGraph == null || hypGraph.isEmpty())
throw new IllegalArgumentException("Invalid hypGraph " + hypGraph);
if (indexes == null)
throw new IllegalArgumentException("Null index array");
if (indexes.length != hypGraph.size())
throw new IllegalArgumentException("Index array length " + indexes.length +
" does not match hypGraph size " + hypGraph.size());
Map<IndexedWord, IndexedWord> map =
Generics.newHashMap();
for (int i = 0; i < indexes.length; i++) {
IndexedWord hypNode = hypGraph.getNodeByIndex(i);
IndexedWord txtNode = IndexedWord.NO_WORD;
if (indexes[i] >= 0)
txtNode = txtGraph.getNodeByIndex(indexes[i]);
map.put(hypNode, txtNode);
}
return new Alignment(map, score, justification);
}
public static Alignment makeFromIndexArray(SemanticGraph txtGraph,View on GitHub (pinned to 1b7edd19c4)