{"record":{"id":"d0eb0483224b1871","repo":"stanfordnlp/CoreNLP","slug":"error-extracting-labelled-spans-for-column","errorCode":null,"errorMessage":"Error extracting labelled spans for column : ","messagePattern":"Error extracting labelled spans for column : ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/coref/docreader/CoNLLDocumentReader.java","lineNumber":453,"sourceCode":"              }\n              t.setSecond(wordPos);\n              spans.add(t);\n            }\n            if (isDelimiter) {\n              lastDelimiterIndex = j;\n            }\n          }\n          if (openParenIndex >= 0) {\n            String s = val.substring(openParenIndex+1, val.length());\n            if (removeStar) {\n              s = starPattern.matcher(s).replaceAll(\"\");\n            }\n            openSpans.push(new Triple<>(wordPos, -1, s));\n          }\n        }\n      }\n      if (openSpans.size() != 0) {\n        throw new RuntimeException(\"Error extracting labelled spans for column \" + fieldIndex + \": \"\n                + concatField(sentWords, fieldIndex));\n      }\n      return spans;\n    }\n\n    private CoreMap wordsToSentence(List<String[]> sentWords) {\n      String sentText = concatField(sentWords, FIELD_WORD);\n      Annotation sentence = new Annotation(sentText);\n      Tree tree = wordsToParse(sentWords);\n      sentence.set(TreeCoreAnnotations.TreeAnnotation.class, tree);\n      List<Tree> leaves = tree.getLeaves();\n      // Check leaves == number of words\n      assert(leaves.size() == sentWords.size());\n      List<CoreLabel> tokens = new ArrayList<>(leaves.size());\n      sentence.set(CoreAnnotations.TokensAnnotation.class, tokens);\n      for (int i = 0; i < sentWords.size(); i++) {\n        String[] fields = sentWords.get(i);\n        int wordPos = Integer.parseInt(fields[FIELD_WORD_NO]);","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/coref/docreader/CoNLLDocumentReader.java#L435-L471","documentation":"At the end of getLabelledSpans, if openSpans is not empty, some label that was opened (e.g. an opening bracket like (LABEL) was never closed by the end of the document. The reader treats unclosed spans as a data-format error and throws, including the field index and the offending column text.","triggerScenarios":"A document in the CoNLL file opens a labelled span (e.g. coref chain start '(12' or NER '(PERSON') but no matching close token appears before the document ends; also triggered by open/close order violations within a token (an open pushed and never popped).","commonSituations":"Truncated corpus files (last lines cut off mid-chain); streaming a partial document; corrupted downloads; custom exporters that emit chain-open markers but drop the close marker on the final mention.","solutions":["Check the file is complete — diff line count / tail against the official CoNLL-2012 gold files","Fix the annotation: every '(LABEL' in the column must have a 'LABEL)' before the end of the document","Re-export your data from the original corpus rather than truncating while streaming","If intentionally processing partial data, pre-close all open spans before the document terminator"],"exampleFix":"// before (chain never closed at end of document)\n token (12\n token 12)\n token (12\n <EOF>\n// after\n token (12\n token 12)\n token (12\n token 12)   <- close every opened chain before EOF","handlingStrategy":"validation","validationCode":"// Ensure every '(LABEL' has a matching 'LABEL)' before end of document\nlong opens = corefColumn.chars().filter(c -> c=='(').count();\nlong closes = corefColumn.chars().filter(c -> c==')').count();\nif (opens != closes) throw new IllegalStateException(\"Unbalanced coref brackets: \" + opens + \" vs \" + closes);","typeGuard":null,"tryCatchPattern":"try { spans = reader.getLabelledSpans(...); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Error extracting labelled spans\")) { log.error(\"Unclosed spans in column: \" + e.getMessage(), e); throw new CorruptAnnotationException(e); } throw e; }","preventionTips":["Check file completeness (line counts) against official gold data","Avoid truncating corpora mid-document","Auto-close open spans at end-of-document in custom exporters","Re-download corrupted files instead of patching"],"tags":["java","conll","unclosed-span","malformed-input"],"backgroundTag":"invalid-argument-format","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"}