Skip to content

Commit

Permalink
better answerline rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Aug 14, 2022
1 parent c4e3bc8 commit 25c3a78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion quizbowl.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ function checkAnswer(answerline, givenAnswer) {
const isFormattedAnswerline = answerline.includes('<u>');
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;
Expand Down
7 changes: 6 additions & 1 deletion tests/quizbowl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const answerline6 = "<b><u>primatology</u></b> [or word forms; accept any answer
const answerline7 = "Heinrich <b><u>Böll</u></b> [or Heinrich Theodor <b><u>Böll</u></b>]";
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'],
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 25c3a78

Please sign in to comment.