stanfordnlp/CoreNLP · error · RuntimeException
Gold Quote List size doesn't match quote list size!
Error message
Gold Quote List size doesn't match quote list size!
What it means
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.
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.
Example fix
// before
featurize(new SieveData(doc, charMap, corefMap, animacySet), goldListFromOtherDoc, true);
// after
List<Pair<Integer,Integer>> gold = readGoldFromSameDoc(doc);
if (gold.size() != doc.get(CoreAnnotations.QuotationsAnnotation.class).size()) {
throw new IllegalArgumentException("gold/quote mismatch before training");
}
featurize(new SieveData(doc, charMap, corefMap, animacySet), gold, true); Defensive patterns
Strategy: validation
Validate before calling
int quoteCount = doc.get(CoreAnnotations.QuotationsAnnotation.class).size();
if (goldList.size() != quoteCount) throw new IllegalArgumentException("gold=" + goldList.size() + " quotes=" + quoteCount); Try / catch
try {
fd = SupervisedSieveTraining.featurize(data, goldList, true);
} catch (RuntimeException e) {
throw new IllegalStateException("Training data misaligned: regenerate gold list", e);
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- LogisticClassifier is only for binary classification!
- Error setting up training
- oldTag starts with B, entity at position should not be null
- Could not read from float initial weight file
- node cliqueFeatures[n]=
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b323d7b1d0dd390b.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/quoteattribution/Sieves/training/SupervisedSieveTraining.java:153
Annotation doc = sd.doc;
// use to access functions
Sieve sieve = new Sieve(doc, sd.characterMap, sd.pronounCorefMap, sd.animacyList);
List<CoreMap> quotes = doc.get(CoreAnnotations.QuotationsAnnotation.class);
List<CoreMap> sentences = doc.get(CoreAnnotations.SentencesAnnotation.class);
List<CoreLabel> tokens = doc.get(CoreAnnotations.TokensAnnotation.class);
Map<Integer, List<CoreMap>> paragraphToQuotes = getQuotesInParagraph(doc);
GeneralDataset<String, String> dataset = new RVFDataset<>();
//necessary for 'ScoreBestMention'
Map<Integer, Pair<Integer, Integer>> mapQuoteToDataRange = new HashMap<>(); //maps quote to corresponding indices in the dataset
Map<Integer, Sieve.MentionData> mapDatumToMention = new HashMap<>();
if(isTraining && goldList.size() != quotes.size()) {
throw new RuntimeException("Gold Quote List size doesn't match quote list size!");
}
for (int quoteIdx = 0; quoteIdx < quotes.size(); quoteIdx++) {
int initialSize = dataset.size();
CoreMap quote = quotes.get(quoteIdx);
XMLToAnnotation.GoldQuoteInfo gold = null;
if(isTraining) {
gold = goldList.get(quoteIdx);
if (gold.speaker.isEmpty()) {
continue;
}
}
CoreMap quoteFirstSentence = sentences.get(quote.get(CoreAnnotations.SentenceBeginAnnotation.class));
Pair<Integer, Integer> quoteRun = new Pair<>(quote.get(CoreAnnotations.TokenBeginAnnotation.class), quote.get(CoreAnnotations.TokenEndAnnotation.class));
// int quoteChapter = quoteFirstSentence.get(ChapterAnnotator.ChapterAnnotation.class);View on GitHub (pinned to 1b7edd19c4)