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 motd = "";
var minMatchAmmount = 50; // TODO
var minMatchAmmount = 50;
// ---------------------------------------------------------------------------------------------
// Class descriptions
// ---------------------------------------------------------------------------------------------
@ -67,7 +67,7 @@ class Question {
if (typeof q2 == 'string') {
var qmatchpercent = Question.CompareString(this.Q, q2);
if (i)
if (i == undefined || i.length == 0)
return qmatchpercent;
else {
if (this.HasImage()) {
@ -200,7 +200,6 @@ class QuestionDB {
r[j] = tmp;
}
console.log(r); // TODO remove dis
return r;
}
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.A; // adding answer
msg += result[k].q.A.replace(/, /g, "\n"); // adding answer
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
@ -738,7 +737,6 @@ function PrepareAnswers(result, j) {
}
function ShowAnswers(answers) {
// TODO: alll / current counter
if (answers.length > 0) { // if there are more than 0 answer
ShowMessage(answers);
} else {
@ -758,7 +756,6 @@ function HandleQuiz(url, count) {
var 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 result = data.Search(question, SimplifyImages(imgNodes));
answers.push(PrepareAnswers(result, j));