From 25c3a7872b6202dd0765a0d0058ff156e3eec1ce Mon Sep 17 00:00:00 2001 From: Geoffrey Wu Date: Sat, 13 Aug 2022 21:01:06 -0400 Subject: [PATCH] better answerline rejection --- quizbowl.js | 8 +++++++- tests/quizbowl.test.js | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/quizbowl.js b/quizbowl.js index d72ea9821..284c09a1c 100644 --- a/quizbowl.js +++ b/quizbowl.js @@ -210,7 +210,13 @@ function checkAnswer(answerline, givenAnswer) { const isFormattedAnswerline = answerline.includes(''); const parsedAnswerline = parseAnswerline(answerline); - for (const type of ['reject', 'accept', 'prompt']) { + for (const answer of parsedAnswerline['reject']) { + if (stringMatchesReference(answer[0], givenAnswer) && stringMatchesReference(givenAnswer, answer[0])) { + return 'reject'; + } + } + + for (const type of ['accept', 'prompt']) { for (const answer of parsedAnswerline[type]) { if (answerWorks(answer[0], givenAnswer, isFormattedAnswerline)) return type; if (answerWorks(answer[1], givenAnswer, isFormattedAnswerline)) return type; diff --git a/tests/quizbowl.test.js b/tests/quizbowl.test.js index c0bb487b1..665ab66c8 100644 --- a/tests/quizbowl.test.js +++ b/tests/quizbowl.test.js @@ -9,7 +9,7 @@ const answerline6 = "primatology [or word forms; accept any answer const answerline7 = "Heinrich Böll [or Heinrich Theodor Böll]"; const answerline8 = "Heinrich Böll [or Heinrich Theodor Böll]"; const answerline9 = "primatology [or word forms; accept any answers about the study of great apes, nonhuman primates, gorillas, bonobos, or chimpanzees; prompt on the study of monkeys or simians; prompt on word forms of ethology, biology, anthropology, or evolutionary or social psychology; prompt on the study of animals with “what type of animals?”]" - +const answerline10 = "China [or People’s Republic of China; do not accept or prompt on “Republic of China”]"; const tests = [ // single answerline ['accept', answerline1, 'manchester'], @@ -49,6 +49,11 @@ const tests = [ // unformatted answerlines ['reject', answerline9, 'chimp'], // TODO: make this accept ['accept', answerline9, 'chimpanzee'], + + // reject clauses that are a subset of acceptable answer + ['accept', answerline10, 'China'], + ['accept', answerline10, 'people’s republic of China'], + ['reject', answerline10, 'republic of china'], ]; let successful = 0, total = 0;