stanfordnlp/CoreNLP · error · RuntimeException
: No 1best segmentation available
Error message
: No 1best segmentation available
What it means
JointParsingModel.GenericLatticeScorer.convertItemSpan maps lattice item offsets to character spans using the stored 1-best segmentation (bestSegmentationB). It throws this RuntimeException when that segmentation is null or empty, since span conversion is impossible without it. This surfaces from latticeEdge/latticeHook during lattice-based joint parse-segment decoding.
Solutions
- Ensure the segmentation stage runs and produces a non-empty 1-best segmentation before lattice parsing.
- Check segmenter output for the sentence; if empty, skip the lattice path or fall back to pipeline parsing.
- Verify the model is constructed so bestSegmentationB is set (correct run mode/flags for joint parsing).
- Guard the caller: validate bestSegmentationB availability before invoking latticeHook-based parsing.
Example fix
// before
hook = model.latticeHook(lattice); // throws when no 1best segmentation
model.parseLattice(hook);
// after
if (model.has1BestSegmentation()) { // check/ensure segmentation is available
hook = model.latticeHook(lattice);
model.parseLattice(hook);
} else {
// fallback: run standard pipeline parsing
} Defensive patterns
Strategy: fallback
Validate before calling
// java: ensure 1-best segmentation exists before lattice decoding
if (bestSegmentationB == null || bestSegmentationB.isEmpty()) {
runSegmentationFirst(sentence); // populate the 1-best segmentation
} Type guard
// java
if (bestSegmentationB == null || bestSegmentationB.isEmpty()) {
return null; // caller falls back to non-lattice parsing
}
Item converted = scorer.convertItemSpan(item); Try / catch
try {
result = jointModel.latticeParse(lattice);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().endsWith("No 1best segmentation available")) {
result = standardPipelineParse(words); // fallback: parse without lattice
} else throw e;
} Prevention
- Always run the segmentation stage before lattice-based joint parsing.
- Handle empty segmenter output (degenerate/empty sentences) with a fallback parse path.
- Assert segmentation availability in integration tests for the parse-segment pipeline.
When it happens
Trigger: Running lattice-based parsing (parse(List<CoreLabel> lattice) with latticeEdge/latticeHook) when the model was never given a 1-best segmentation — bestSegmentationB is null or empty at convertItemSpan time.
Common situations: Invoking the lattice parse path without first running the segmentation step that populates bestSegmentationB; a segmenter that returned zero segments for degenerate/empty input; misconfigured pipeline ordering in the parse-segment model.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- : Parser grammar does not exist
- : Does not support parse operation.
- this.getClass().getName() + ": Case is presently…
- Arabic does not support feature type: " + feat.toString()
- This version of the parser does not support non-tree…
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/7b9614f3d72307cf.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/international/arabic/parsesegment/JointParsingModel.java:331
lexNumRules);
log.info("ParserPack is " + op.tlpParams.getClass().getName());
log.info("Lexicon is " + lp.lex.getClass().getName());
}
return parse(inputStream);
}
/*
* pparser chart uses segmentation interstices; dparser uses 1best word
* interstices. Convert between the two here for bparser.
*/
private static class GenericLatticeScorer implements LatticeScorer {
@Override
public Item convertItemSpan(Item item) {
if(bestSegmentationB == null || bestSegmentationB.isEmpty())
throw new RuntimeException(this.getClass().getName() + ": No 1best segmentation available");
item.start = bestSegmentationB.get(item.start).beginPosition();
item.end = bestSegmentationB.get(item.end - 1).endPosition();
return item;
}
@Override
public double oScore(Edge edge) {
final Edge latticeEdge = (Edge) convertItemSpan(new Edge(edge));
double pOscore = pparser.oScore(latticeEdge);
double dOscore = dparser.oScore(edge);
return pOscore + dOscore;
}
@Override
public double iScore(Edge edge) {View on GitHub (pinned to 1b7edd19c4)