Skip to content

Commit

Permalink
fix answer parsing of form a or b
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Nov 18, 2022
1 parent 1c628ef commit f2d9a73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions server/quizbowl.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ function parseAnswerline(answerline) {
reject: []
}

if (mainAnswer.includes(' or ')) {
let parts = mainAnswer.split(' or ');
parsedAnswerline.accept.push([extractUnderlining(parts[0]), extractKeyWords(parts[0]), extractQuotes(parts[0])]);
parsedAnswerline.accept.push([extractUnderlining(parts[1]), extractKeyWords(parts[1]), extractQuotes(parts[1])]);
}

subPhrases.forEach(phrase => {
if (phrase.length === 0) return;
const { directive, answers } = splitIntoAnswers(phrase);
Expand Down
17 changes: 11 additions & 6 deletions tests/quizbowl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ const formatted_answers = [
"The <b><u>Wasteland</u></b>",
"<b><u>W</u></b>orld <b><u>T</u></b>rade <b><u>O</u></b>rganization",
"The (Holy) <b><u>Grail</u></b>",
"<b><u>coagulation</u></b> or blood <b><u>clotting</u></b>",

// or in the main answer,
// TODO: or in the main answer
// and commas instead of semicolons or "or" in alternate answer
"<b><u>Furies</u></b> or <b><u>Erinyes</u></b> [accept <b><u>Eumenides</u></b>, <b><u>Semnai</u></b>, or <b><u>Dirae</u></b>]",
// "<b><u>Furies</u></b> or <b><u>Erinyes</u></b> [accept <b><u>Eumenides</u></b>, <b><u>Semnai</u></b>, or <b><u>Dirae</u></b>]",
];

const answers = [
Expand Down Expand Up @@ -161,10 +162,14 @@ const tests = [
['accept', formatted_answers[25], 'grail'],
['accept', formatted_answers[25], 'holy grail'],

['accept', formatted_answers[26], 'Furies'],
['accept', formatted_answers[26], 'Erinyes'],
['accept', formatted_answers[26], 'Eumenides'],
['accept', formatted_answers[26], 'Semnai'],
['accept', formatted_answers[26], 'coagulation'],
['accept', formatted_answers[26], 'clotting'],
['accept', formatted_answers[26], 'blood clotting'],

// ['accept', formatted_answers[27], 'Furies'],
// ['accept', formatted_answers[27], 'Erinyes'],
// ['accept', formatted_answers[27], 'Eumenides'],
// ['accept', formatted_answers[27], 'Semnai'],

['accept', answers[0], 'boll'],
['accept', answers[0], 'heinrich boll'],
Expand Down

0 comments on commit f2d9a73

Please sign in to comment.