Removed Jeopardy questions containing URLs. Including first letter in first hint.

This commit is contained in:
ThePendulum 2021-11-14 19:55:14 +01:00
parent 268735b3a8
commit c23c3ffd32
6 changed files with 4901 additions and 111405 deletions

View File

@ -1,20 +1,28 @@
'use strict'; 'use strict';
const fs = require('fs').promises; const fs = require('fs').promises;
const linkify = require('linkify-it')();
const questions = require('./jeopardy_raw.json'); const questions = require('./jeopardy_raw.json');
async function init() { async function init() {
const curatedQuestions = questions.map((question) => ({ const curatedQuestions = await Promise.all(questions.map(async (question) => {
...question, const links = linkify.match(question.question);
question: question.question.replace(/^'|'$/g, ''),
answer: question.answer.replace(/^((the|an|a)\b(?!-)|\(.*\))\s*|\(.*\)$|"/gi, ''), if (links?.length > 0 || /\[jpe?g\]/.test(question.question)) {
fullAnswer: question.answer, console.log(`Discarding question due URL: ${question.question}`);
return null;
}
return {
...question,
question: question.question.replace(/^'|'$/g, ''),
answer: question.answer.replace(/^((the|an|a)\b(?!-)|\(.*\))\s*|\(.*\)$|"|\\/gi, ''),
fullAnswer: question.answer,
};
})); }));
await fs.writeFile('assets/jeopardy.json', JSON.stringify(curatedQuestions, null, 4)); await fs.writeFile('assets/jeopardy.json', JSON.stringify(curatedQuestions.filter(Boolean), null, 4));
console.log(curatedQuestions);
} }
init(); init();

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ module.exports = {
trivia: { trivia: {
mode: 'first', // first or timeout mode: 'first', // first or timeout
rounds: 10, rounds: 10,
timeout: 30, timeout: 60,
}, },
duck: { duck: {
interval: [10, 3600], // seconds interval: [10, 3600], // seconds

1009
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,10 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"bhttp": "^1.2.8", "bhttp": "^1.2.8",
"bottleneck": "^2.19.5",
"config": "^3.3.6", "config": "^3.3.6",
"jsdom": "^18.1.0",
"linkify-it": "^3.0.3",
"simple-node-logger": "^21.8.12", "simple-node-logger": "^21.8.12",
"ws": "^8.2.3", "ws": "^8.2.3",
"yargs": "^17.2.1" "yargs": "^17.2.1"

View File

@ -59,14 +59,14 @@ async function playRound(context, round = 0) {
}); });
// replace space with U+2003 Em Space to separate words, since a single space separates the placeholders, and double spaces are removed during Markdown render // replace space with U+2003 Em Space to separate words, since a single space separates the placeholders, and double spaces are removed during Markdown render
context.sendMessage(`**${Math.floor(game.timeout / 3) * 2} seconds** left, first hint for round ${round + 1}/${game.questions.length}: ${question.answer.replace(/\s/g, '').replace(/[^\s]/g, '_ ')}`, context.room.id); context.sendMessage(`**${Math.floor(game.timeout / 3) * 2} seconds** left, first hint for **round ${round + 1}/${game.questions.length}**: ${question.answer.slice(0, 1)}${question.answer.slice(1).replace(/\s/g, '').replace(/[^\s]/g, '_ ')}`, context.room.id);
await timers.setTimeout((game.timeout / 3) * 1000, null, { await timers.setTimeout((game.timeout / 3) * 1000, null, {
signal: ac.signal, signal: ac.signal,
}); });
if (question.answer.length > 3) { if (question.answer.length > 3) {
context.sendMessage(`**${Math.floor(game.timeout / 3)} seconds** left, second hint for round ${round + 1}/${game.questions.length}: **${question.answer.slice(0, 1)} ${question.answer.slice(1).replace(/\s/g, '').replace(/[^\s]/g, '_ ')}${question.answer.slice(-1)}**`, context.room.id); context.sendMessage(`**${Math.floor(game.timeout / 3)} seconds** left, second hint for **round ${round + 1}/${game.questions.length}**: **${question.answer.slice(0, 1)} ${question.answer.slice(1).replace(/\s/g, '').replace(/[^\s]/g, '_ ')}${question.answer.slice(-1)}**`, context.room.id);
} }
await timers.setTimeout((game.timeout / 3) * 1000, null, { await timers.setTimeout((game.timeout / 3) * 1000, null, {