Question answering fixes

This commit is contained in:
YourFriendlyNeighborhoodDealer 2018-12-13 16:06:21 +01:00
parent 599fac2928
commit 8956cbade9

View file

@ -34,7 +34,7 @@ const logElementGetting = false;
var motdShowCount = 3; var motdShowCount = 3;
var motd = ""; var motd = "";
var minMatchAmmount = 50; // TODO var minMatchAmmount = 50;
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
// Class descriptions // Class descriptions
// --------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------
@ -67,7 +67,7 @@ class Question {
if (typeof q2 == 'string') { if (typeof q2 == 'string') {
var qmatchpercent = Question.CompareString(this.Q, q2); var qmatchpercent = Question.CompareString(this.Q, q2);
if (i) if (i == undefined || i.length == 0)
return qmatchpercent; return qmatchpercent;
else { else {
if (this.HasImage()) { if (this.HasImage()) {
@ -200,7 +200,6 @@ class QuestionDB {
r[j] = tmp; r[j] = tmp;
} }
console.log(r); // TODO remove dis
return r; return r;
} }
AddSubject(subj) { AddSubject(subj) {
@ -723,7 +722,7 @@ function PrepareAnswers(result, j) {
{ {
msg += result[k].q.Q + "\n"; // adding the question if yes msg += result[k].q.Q + "\n"; // adding the question if yes
} }
msg += result[k].q.A; // adding answer msg += result[k].q.A.replace(/, /g, "\n"); // adding answer
if (result[k].q.HasImage()) // and adding image, if it exists if (result[k].q.HasImage()) // and adding image, if it exists
{ {
msg += "\n" + result[k].q.I; // if it has image part, adding that too msg += "\n" + result[k].q.I; // if it has image part, adding that too
@ -738,7 +737,6 @@ function PrepareAnswers(result, j) {
} }
function ShowAnswers(answers) { function ShowAnswers(answers) {
// TODO: alll / current counter
if (answers.length > 0) { // if there are more than 0 answer if (answers.length > 0) { // if there are more than 0 answer
ShowMessage(answers); ShowMessage(answers);
} else { } else {
@ -758,7 +756,6 @@ function HandleQuiz(url, count) {
var answers = []; var answers = [];
for (var j = 0; j < questions.length; j++) // going thru all answers for (var j = 0; j < questions.length; j++) // going thru all answers
{ {
// TODO: images, and other stuffs
var question = RemoveUnnecesarySpaces(questions[j]); // simplifying question var question = RemoveUnnecesarySpaces(questions[j]); // simplifying question
var result = data.Search(question, SimplifyImages(imgNodes)); var result = data.Search(question, SimplifyImages(imgNodes));
answers.push(PrepareAnswers(result, j)); answers.push(PrepareAnswers(result, j));