Skip to content

Commit d663e6c

Browse files
committed
close #63
1 parent b47e1e0 commit d663e6c

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

server/quizbowl.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ function parseAnswerline(answerline) {
7777
}
7878
}
7979

80+
/**
81+
* Get all words which are partially or wholly underlined.
82+
*/
8083
const extractKeyWords = (string) => {
8184
const tokens = string.split(' ');
8285
return tokens.filter(token => token.length > 0 && token.match(/<[^>]*>/))
@@ -216,6 +219,16 @@ function checkAnswer(answerline, givenAnswer) {
216219
}
217220
}
218221

222+
if (answerline.includes('[accept either') || answerline.includes('(accept either')) {
223+
const [answer1, answer2] = parsedAnswerline.accept[0][0].split(' ');
224+
if (answerWorks(answer1, givenAnswer, isFormattedAnswerline)) {
225+
return 'accept';
226+
}
227+
if (answerWorks(answer2, givenAnswer, isFormattedAnswerline)) {
228+
return 'accept';
229+
}
230+
}
231+
219232
for (const type of ['accept', 'prompt']) {
220233
for (const answer of parsedAnswerline[type]) {
221234
if (answerWorks(answer[0], givenAnswer, isFormattedAnswerline)) return type;

tests/quizbowl.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const formatted_answers = [
1010
"<b><u>primatology</u></b> [or word forms; accept any answers about the study of great <b><u>ape</u></b>s, nonhuman <b><u>primate</u></b>s, <b><u>gorilla</u></b>s, <b><u>bonobo</u></b>s, or <b><u>chimp</u></b>anzees; prompt on the study of <u>monkey</u>s or <u>simian</u>s; prompt on word forms of <u>ethology</u>, <u>biology</u>, <u>anthropology</u>, or evolutionary or social <u>psychology</u>; prompt on the study of <u>animal</u>s with “what type of animals?”]",
1111
"Heinrich <b><u>Böll</u></b> [or Heinrich Theodor <b><u>Böll</u></b>]",
1212
"<b><u>Louis-Philippe</u></b> [or <b><u>Duke d’Orleans</u></b>; prompt on “Citizen King” before mentioned]",
13+
"Johann <b><u>Tserclaes</u></b>, Graf von <b><u>Tilly</u></b> (accept either underlined answer as well as Count of <b><u>Tilly</u></b>)",
14+
"<b><u>Paul</u></b> <b><u>Bäumer</u></b> [accept either name]",
15+
"<b><u>Matsuo</u></b> <b><u>Bashō</u></b> [accept either underlined part; accept <b><u>Matsuo</u></b> Kinsaku or <b><u>Matsuo</u></b> Chūemon Munefusa]"
1316
];
1417

1518
const answers = [
@@ -59,6 +62,23 @@ const tests = [
5962
['reject', formatted_answers[8], 'Louis'],
6063
['reject', formatted_answers[8], 'Philippe'],
6164

65+
// accept either clauses
66+
['accept', formatted_answers[9], 'Tserclaes'],
67+
['accept', formatted_answers[9], 'Tilly'],
68+
['accept', formatted_answers[9], 'Count of Tilly'],
69+
70+
// accept either clauses with special characters
71+
['accept', formatted_answers[10], 'Baumer'],
72+
['accept', formatted_answers[10], 'Bäumer'],
73+
['accept', formatted_answers[10], 'Paul'],
74+
['accept', formatted_answers[10], 'Paul Bäumer'],
75+
76+
['accept', formatted_answers[11], 'Basho'],
77+
['accept', formatted_answers[11], 'Bashō'],
78+
['accept', formatted_answers[11], 'Matsuo'],
79+
['accept', formatted_answers[11], 'Matsuo Basho'],
80+
['accept', formatted_answers[11], 'Matsuo Bashō'],
81+
6282
['accept', answers[0], 'boll'],
6383
['accept', answers[0], 'heinrich boll'],
6484
['accept', answers[0], 'Böll'],

0 commit comments

Comments
 (0)