{"record":{"id":"b323d7b1d0dd390b","repo":"stanfordnlp/CoreNLP","slug":"gold-quote-list-size-doesn-t-match-quote-list-size","errorCode":null,"errorMessage":"Gold Quote List size doesn't match quote list size!","messagePattern":"Gold Quote List size doesn't match quote list size!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/quoteattribution/Sieves/training/SupervisedSieveTraining.java","lineNumber":153,"sourceCode":"\n    Annotation doc = sd.doc;\n\n    // use to access functions\n    Sieve sieve = new Sieve(doc, sd.characterMap, sd.pronounCorefMap, sd.animacyList);\n\n    List<CoreMap> quotes = doc.get(CoreAnnotations.QuotationsAnnotation.class);\n    List<CoreMap> sentences = doc.get(CoreAnnotations.SentencesAnnotation.class);\n    List<CoreLabel> tokens = doc.get(CoreAnnotations.TokensAnnotation.class);\n\n    Map<Integer, List<CoreMap>> paragraphToQuotes = getQuotesInParagraph(doc);\n    GeneralDataset<String, String> dataset = new RVFDataset<>();\n\n    //necessary for 'ScoreBestMention'\n    Map<Integer, Pair<Integer, Integer>> mapQuoteToDataRange = new HashMap<>(); //maps quote to corresponding indices in the dataset\n    Map<Integer, Sieve.MentionData> mapDatumToMention = new HashMap<>();\n\n    if(isTraining && goldList.size() != quotes.size()) {\n      throw new RuntimeException(\"Gold Quote List size doesn't match quote list size!\");\n    }\n\n    for (int quoteIdx = 0; quoteIdx < quotes.size(); quoteIdx++) {\n\n      int initialSize = dataset.size();\n\n      CoreMap quote = quotes.get(quoteIdx);\n      XMLToAnnotation.GoldQuoteInfo gold = null;\n      if(isTraining) {\n        gold = goldList.get(quoteIdx);\n        if (gold.speaker.isEmpty()) {\n          continue;\n        }\n      }\n\n      CoreMap quoteFirstSentence = sentences.get(quote.get(CoreAnnotations.SentenceBeginAnnotation.class));\n      Pair<Integer, Integer> quoteRun = new Pair<>(quote.get(CoreAnnotations.TokenBeginAnnotation.class), quote.get(CoreAnnotations.TokenEndAnnotation.class));\n//      int quoteChapter = quoteFirstSentence.get(ChapterAnnotator.ChapterAnnotation.class);","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/quoteattribution/Sieves/training/SupervisedSieveTraining.java#L135-L171","documentation":"SupervisedSieveTraining.featurize, when invoked in training mode (isTraining=true), requires each quote to have a corresponding gold mention. If goldList.size() != quotes.size() it throws RuntimeException(\"Gold Quote List size doesn't match quote list size!\") at src/edu/stanford/nlp/quoteattribution/Sieves/training/SupervisedSieveTraining.java:153. It is a dataset-consistency invariant: feature/label pairs are built index-aligned, so a mismatch makes training data invalid.","triggerScenarios":"Calling featurize with isTraining=true and a gold list extracted from an annotation document whose QuotesAnnotation count differs from the gold annotations (mismatched XML, dropped quotes during parsing, partially annotated document).","commonSituations":"Training data XML where some quotes were not annotated with authors; gold list built from a different document revision; quotes filtered/removed upstream but gold list not filtered identically.","solutions":["Regenerate the gold list from the exact same document/Annotation passed to featurize.","Check that XML quote extraction (XMLToAnnotation) parsed all quotes — fix malformed quote markup so counts align.","Filter goldList and quotes identically before calling featurize.","Pass isTraining=false if you only need inference featurization and no gold labels."],"exampleFix":"// before\nfeaturize(new SieveData(doc, charMap, corefMap, animacySet), goldListFromOtherDoc, true);\n// after\nList<Pair<Integer,Integer>> gold = readGoldFromSameDoc(doc);\nif (gold.size() != doc.get(CoreAnnotations.QuotationsAnnotation.class).size()) {\n  throw new IllegalArgumentException(\"gold/quote mismatch before training\");\n}\nfeaturize(new SieveData(doc, charMap, corefMap, animacySet), gold, true);","handlingStrategy":"validation","validationCode":"int quoteCount = doc.get(CoreAnnotations.QuotationsAnnotation.class).size();\nif (goldList.size() != quoteCount) throw new IllegalArgumentException(\"gold=\" + goldList.size() + \" quotes=\" + quoteCount);","typeGuard":null,"tryCatchPattern":"try {\n  fd = SupervisedSieveTraining.featurize(data, goldList, true);\n} catch (RuntimeException e) {\n  throw new IllegalStateException(\"Training data misaligned: regenerate gold list\", e);\n}","preventionTips":["Derive gold list from the same Annotation/document passed to featurize","Keep gold and text files versioned together","Add a pre-training count assertion in your harness"],"tags":["java","dataset","training","invariant"],"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"}