{"record":{"id":"7963847612e18d95","repo":"stanfordnlp/CoreNLP","slug":"quotes-size-and-gold-size-don-t-match","errorCode":null,"errorMessage":"Quotes size and gold size don't match!","messagePattern":"Quotes size and gold size don't match!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/quoteattribution/XMLToAnnotation.java","lineNumber":307,"sourceCode":"            }\n            tokenIndex = getEndIndex(tokenIndex, tokens, nodeText) + 1;\n          }\n        }\n      }\n    }\n    for(Pair<Integer, String> item : mentionIdToSpeakerList) {\n      Mention mention = idToMention.get(item.first);\n      if(mention == null) {\n        goldList.add(new GoldQuoteInfo(-1, -1, item.second, null));\n      } else {\n        goldList.add(new GoldQuoteInfo(mention.begin, mention.end, item.second, mention.text));\n      }\n\n    }\n\n    //verify\n    if(document.get(CoreAnnotations.QuotationsAnnotation.class).size() != goldList.size()) {\n      throw new RuntimeException(\"Quotes size and gold size don't match!\");\n    }\n\n    return new Data(goldList, personList, document);\n  }\n}\n","sourceCodeStart":289,"sourceCodeEnd":313,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/quoteattribution/XMLToAnnotation.java#L289-L313","documentation":"XMLToAnnotation.readXMLFormat parses a quote-attribution XML corpus into quotes and a gold author list, then verifies counts match. If document.get(CoreAnnotations.QuotationsAnnotation.class).size() != goldList.size() it throws RuntimeException(\"Quotes size and gold size don't match!\") at src/edu/stanford/nlp/quoteattribution/XMLToAnnotation.java:307. The check exists because gold entries must map 1:1 onto extracted quotes for training/evaluation Data.","triggerScenarios":"Calling readXMLFormat on an XML file where the number of quote elements successfully parsed into the document differs from the number of gold author entries — e.g. nested/malformed quote tags, a quote element missing required attributes, or gold entries added for text that was not recognized as a quote.","commonSituations":"Hand-edited or third-party XML corpora with inconsistent quote markup; XML entities or line breaks breaking quote detection; gold annotation files not regenerated after editing the text.","solutions":["Validate the XML quote markup (properly nested, well-formed <quote> elements) and re-run.","Log both sizes and diff which quote index diverged; fix the offending paragraph.","Regenerate the gold list from the same XML file version used for parsing.","Escape/normalize special characters and whitespace so the quote tokenizer sees the same quotes as the annotator."],"exampleFix":"// before\nData d = new XMLToAnnotation(pipeline).readXMLFormat(\"book.xml\"); // mismatch\n// after (pre-validate)\nDocument dom = ...; int goldCount = dom.getElementsByTagName(\"author\").getLength();\nint quoteCount = dom.getElementsByTagName(\"quote\").getLength();\nif (goldCount != quoteCount) throw new IllegalArgumentException(\"fix XML: quotes=\" + quoteCount + \" gold=\" + goldCount);\nData d = new XMLToAnnotation(pipeline).readXMLFormat(\"book.xml\");","handlingStrategy":"validation","validationCode":"Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xml);\nint q = dom.getElementsByTagName(\"quote\").getLength();\nint g = dom.getElementsByTagName(\"author\").getLength();\nif (q != g) throw new IllegalArgumentException(\"XML quotes/gold mismatch: \" + q + \" vs \" + g);","typeGuard":null,"tryCatchPattern":"try {\n  Data d = reader.readXMLFormat(file);\n} catch (RuntimeException e) {\n  if (e.getMessage().contains(\"don't match\")) log.severe(\"Fix XML quote markup in \" + file);\n  throw e;\n}","preventionTips":["Validate XML against the expected quote schema before ingestion","Avoid hand-editing annotated corpora; regenerate gold after edits","Escape special characters so quote detection matches annotation"],"tags":["java","xml","dataset","validation"],"backgroundTag":"schema-validation-failed","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"}