{"record":{"id":"ad3f8a0a732ec63f","repo":"stanfordnlp/CoreNLP","slug":"no-more-elements-from-inputdesc","errorCode":null,"errorMessage":"No more elements from ${inputDesc}","messagePattern":"No more elements from (.+?)","errorType":"exception","errorClass":"java.util.NoSuchElementException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/charniak/CharniakScoredParsesReaderWriter.java","lineNumber":253,"sourceCode":"    public List<ScoredObject<Tree>> next() {\n      if (!done) {\n        List<ScoredObject<Tree>> cur = next;\n        next = getNext();\n        processed++;\n        if (next == null) {\n          logger.info(\"Read \" + processed + \" trees, from \"\n                  + inputDesc + \" in \" + timing.toSecondsString() + \" secs\");\n          done = true;\n          if (closeBufferNeeded) {\n            try { br.close();\n            } catch (IOException ex) {\n              logger.warn(ex);\n            }\n          }\n        }\n        return cur;\n      } else {\n        throw new NoSuchElementException(\"No more elements from \" + inputDesc);\n      }\n    }\n  } // end static class ScoredParsesIterator\n\n}\n","sourceCodeStart":235,"sourceCodeEnd":259,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/charniak/CharniakScoredParsesReaderWriter.java#L235-L259","documentation":"CharniakScoredParsesReaderWriter's ScoredParsesIterator.next() throws NoSuchElementException when the underlying input has no more scored parses to read. This is the standard Iterator contract: next() called past the end of the parse stream. inputDesc identifies which input file/stream was exhausted.","triggerScenarios":"Calling next() on the returned iterator after hasNext() returned false, or calling next() without checking hasNext() while iterating a Charniak parse dump file that has fewer entries than expected.","commonSituations":"Assuming a k-best parse file always contains k parses per sentence; iterating with next() instead of a hasNext() guard; a truncated or corrupt parse dump ending earlier than the driver loop expects.","solutions":["Guard each call with iterator.hasNext() before calling next()","Use a for-each loop over the iterable instead of manual next() calls","Verify the input parse file is complete and not truncated"],"exampleFix":"// before\nwhile (true) { ScoredObject<Tree> so = it.next(); ... }\n// after\nwhile (it.hasNext()) { ScoredObject<Tree> so = it.next(); ... }","handlingStrategy":"type-guard","validationCode":"if (it == null || !it.hasNext()) { return Collections.emptyListIterator(); }","typeGuard":"static <T> Optional<T> nextIfPresent(Iterator<T> it) { return it != null && it.hasNext() ? Optional.of(it.next()) : Optional.empty(); }","tryCatchPattern":"try { so = it.next(); } catch (NoSuchElementException e) { log.warn(\"parse stream exhausted early: \" + inputDesc); break; }","preventionTips":["Always iterate with hasNext() or for-each, never bare next() calls","Validate that parse dump files contain the expected number of entries before consuming them","Handle truncated inputs gracefully instead of assuming fixed k-best counts"],"tags":["java","iterator","no-such-element"],"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"}