{"record":{"id":"7b9614f3d72307cf","repo":"stanfordnlp/CoreNLP","slug":"no-1best-segmentation-available","errorCode":null,"errorMessage":": No 1best segmentation available","messagePattern":": No 1best segmentation available","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/international/arabic/parsesegment/JointParsingModel.java","lineNumber":331,"sourceCode":"                         lexNumRules);\n      log.info(\"ParserPack is \" + op.tlpParams.getClass().getName());\n      log.info(\"Lexicon is \" + lp.lex.getClass().getName());\n    }\n\n    return parse(inputStream);\n  }\n\n\n  /*\n   * pparser chart uses segmentation interstices; dparser uses 1best word\n   * interstices. Convert between the two here for bparser.\n   */\n  private static class GenericLatticeScorer implements LatticeScorer {\n\n    @Override\n    public Item convertItemSpan(Item item) {\n      if(bestSegmentationB == null || bestSegmentationB.isEmpty())\n        throw new RuntimeException(this.getClass().getName() + \": No 1best segmentation available\");\n\n      item.start = bestSegmentationB.get(item.start).beginPosition();\n      item.end = bestSegmentationB.get(item.end - 1).endPosition();\n      return item;\n    }\n\n    @Override\n    public double oScore(Edge edge) {\n      final Edge latticeEdge = (Edge) convertItemSpan(new Edge(edge));\n\n      double pOscore = pparser.oScore(latticeEdge);\n      double dOscore = dparser.oScore(edge);\n\n      return pOscore + dOscore;\n    }\n\n    @Override\n    public double iScore(Edge edge) {","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/arabic/parsesegment/JointParsingModel.java#L313-L349","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nhook = model.latticeHook(lattice); // throws when no 1best segmentation\nmodel.parseLattice(hook);\n// after\nif (model.has1BestSegmentation()) { // check/ensure segmentation is available\n  hook = model.latticeHook(lattice);\n  model.parseLattice(hook);\n} else {\n  // fallback: run standard pipeline parsing\n}","handlingStrategy":"fallback","validationCode":"// java: ensure 1-best segmentation exists before lattice decoding\nif (bestSegmentationB == null || bestSegmentationB.isEmpty()) {\n  runSegmentationFirst(sentence); // populate the 1-best segmentation\n}","typeGuard":"// java\nif (bestSegmentationB == null || bestSegmentationB.isEmpty()) {\n  return null; // caller falls back to non-lattice parsing\n}\nItem converted = scorer.convertItemSpan(item);","tryCatchPattern":"try {\n  result = jointModel.latticeParse(lattice);\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().endsWith(\"No 1best segmentation available\")) {\n    result = standardPipelineParse(words); // fallback: parse without lattice\n  } else throw e;\n}","preventionTips":["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."],"tags":["java","nlp","arabic","segmentation","parser"],"backgroundTag":"empty-result-set","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"}