private QuestionPackData CreateSingleQuestionPackData()
        {
            var teacher = AppManager.I.Teacher;

            // Ordered words
            var words = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetWordsByCategory(category, parameters.wordFilters),
                new SelectionParameters(parameters.correctSeverity, getMaxData: true, useJourney: parameters.useJourneyForCorrect)
                );

            // sort by id
            words.Sort((x, y) =>
            {
                return(x.Id.CompareTo(y.Id));
            }
                       );

            if (ConfigAI.verboseTeacher)
            {
                string debugString = "Words: " + words.Count;
                foreach (var w in words)
                {
                    debugString += " " + w;
                }
                UnityEngine.Debug.Log(debugString);
            }

            return(QuestionPackData.CreateFromCorrect(null, words));
        }
示例#2
0
        public QuestionPackData CreateAlphabetQuestionPackData()
        {
            var teacher = AppManager.I.Teacher;

            // Fully ordered alphabet, only 1 pack
            var alphabetLetters = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetAllLetters(parameters.letterFilters),
                new SelectionParameters(parameters.correctSeverity, getMaxData: true, useJourney: parameters.useJourneyForCorrect)
                );

            alphabetLetters.Sort((x, y) =>
            {
                return(x.Number - y.Number);
            }
                                 );

            if (ConfigAI.verboseTeacher)
            {
                string debugString = "Letters: " + alphabetLetters.Count;
                foreach (var l in alphabetLetters)
                {
                    debugString += " " + l;
                }
                UnityEngine.Debug.Log(debugString);
            }

            return(QuestionPackData.CreateFromCorrect(null, alphabetLetters));
        }
示例#3
0
        public static QuestionPackData CreateFromWrong <T2>(IConvertibleToLivingLetterData question, List <T2> wrongAnswers) where T2 : IConvertibleToLivingLetterData
        {
            QuestionPackData questionPackData = new QuestionPackData();

            questionPackData.question     = question;
            questionPackData.wrongAnswers = wrongAnswers.ConvertAll <IConvertibleToLivingLetterData>(x => (IConvertibleToLivingLetterData)x);
            return(questionPackData);
        }
示例#4
0
        public static QuestionPackData CreateFromCorrect <T1>(IConvertibleToLivingLetterData question, List <T1> correctAnswers) where T1 : IConvertibleToLivingLetterData
        {
            QuestionPackData questionPackData = new QuestionPackData();

            questionPackData.question       = question;
            questionPackData.correctAnswers = correctAnswers.ConvertAll <IConvertibleToLivingLetterData>(x => (IConvertibleToLivingLetterData)x);
            return(questionPackData);
        }
示例#5
0
        public static QuestionPackData Create <T1, T2>(List <T1> questions, List <T2> correctAnswers, List <T2> wrongAnswers) where T1 : IConvertibleToLivingLetterData where T2 : IConvertibleToLivingLetterData
        {
            QuestionPackData questionPackData = new QuestionPackData();

            questionPackData.questions      = questions.ConvertAll <IConvertibleToLivingLetterData>(x => (IConvertibleToLivingLetterData)x);
            questionPackData.correctAnswers = correctAnswers.ConvertAll <IConvertibleToLivingLetterData>(x => (IConvertibleToLivingLetterData)x);
            questionPackData.wrongAnswers   = wrongAnswers.ConvertAll <IConvertibleToLivingLetterData>(x => (IConvertibleToLivingLetterData)x);
            return(questionPackData);
        }
        public List <QuestionPackData> CreateAllQuestionPacks()
        {
            List <QuestionPackData> packs = new List <QuestionPackData>();
            var teacher = AppManager.I.Teacher;

            var db      = AppManager.I.DB;
            var choice1 = db.GetWordDataById("the_sun");
            var choice2 = db.GetWordDataById("the_moon");

            var wordsWithArticle = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetWordsByArticle(Db.WordDataArticle.Determinative, parameters.wordFilters),
                new SelectionParameters(parameters.correctSeverity, nPacks, useJourney: parameters.useJourneyForCorrect)
                );

            foreach (var wordWithArticle in wordsWithArticle)
            {
                int articleLength      = 2;
                var letterAfterArticle = teacher.wordHelper.GetLettersInWord(wordWithArticle)[articleLength];
                var correctWords       = new List <Db.WordData>();
                var wrongWords         = new List <Db.WordData>();
                switch (letterAfterArticle.SunMoon)
                {
                case Db.LetterDataSunMoon.Sun:
                    correctWords.Add(choice1);
                    wrongWords.Add(choice2);
                    break;

                case Db.LetterDataSunMoon.Moon:
                    correctWords.Add(choice2);
                    wrongWords.Add(choice1);
                    break;
                }

                // Debug
                if (ConfigAI.verboseTeacher)
                {
                    string debugString = "--------- TEACHER: question pack result ---------";
                    debugString += "\nQuestion: " + wordWithArticle;
                    debugString += "\nCorrect Word: " + correctWords.Count;
                    foreach (var l in correctWords)
                    {
                        debugString += " " + l;
                    }
                    debugString += "\nWrong Word: " + wrongWords.Count;
                    foreach (var l in wrongWords)
                    {
                        debugString += " " + l;
                    }
                    UnityEngine.Debug.Log(debugString);
                }

                var pack = QuestionPackData.Create(wordWithArticle, correctWords, wrongWords);
                packs.Add(pack);
            }

            return(packs);
        }
        private QuestionPackData CreateSingleQuestionPackData()
        {
            var teacher = AppManager.I.Teacher;

            // Get a phrase
            int nToUse        = 1;
            var usablePhrases = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetAllPhrases(
                    parameters.wordFilters,
                    parameters.phraseFilters),
                new SelectionParameters(parameters.correctSeverity, nToUse, useJourney: parameters.useJourneyForCorrect,
                                        packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs));
            var question = usablePhrases[0];

            // Get words related to the phrase
            var correctWords = new List <Db.WordData>();
            List <Db.WordData> relatedWords = null;

            if (usePhraseAnswersIfFound && question.Answers.Length > 0)
            {
                relatedWords = teacher.wordHelper.GetAnswersToPhrase(question, parameters.wordFilters);
            }
            else
            {
                relatedWords = teacher.wordHelper.GetWordsInPhrase(question, parameters.wordFilters);
            }

            correctWords.AddRange(relatedWords);
            if (!useAllCorrectWords)
            {
                correctWords = correctWords.RandomSelect(nCorrect);
            }

            var wrongWords = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetWordsNotIn(parameters.wordFilters, relatedWords.ToArray()),
                new SelectionParameters(parameters.correctSeverity, nWrong, useJourney: parameters.useJourneyForCorrect,
                                        packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs));

            if (ConfigAI.verboseTeacher)
            {
                string debugString = "--------- TEACHER: question pack result ---------";
                debugString += "\nQuestion: " + question;
                debugString += "\nCorrect Answers: " + correctWords.Count;
                foreach (var l in correctWords)
                {
                    debugString += " " + l;
                }
                debugString += "\nWrong Answers: " + wrongWords.Count;
                foreach (var l in wrongWords)
                {
                    debugString += " " + l;
                }
                UnityEngine.Debug.Log(debugString);
            }

            return(QuestionPackData.Create(question, correctWords, wrongWords));
        }
        private QuestionPackData CreateSingleQuestionPackData()
        {
            var teacher = AppManager.I.Teacher;

            // Get a word
            var usableWords = teacher.wordAI.SelectData(
                () => FindEligibleWords(maxWordLength: this.maximumWordLength),
                new SelectionParameters(parameters.correctSeverity, 1, useJourney: parameters.useJourneyForCorrect,
                                        packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs));
            var question = usableWords[0];

            // Get letters of that word
            var wordLetters = teacher.wordHelper.GetLettersInWord(question);

            bool useJourneyForLetters = parameters.useJourneyForCorrect;

            if (useAllCorrectLetters)
            {
                useJourneyForLetters = false;                        // @note: we force journey in this case to be off so that all letters can be found
            }
            var correctAnswers = teacher.wordAI.SelectData(
                () => wordLetters,
                new SelectionParameters(parameters.correctSeverity, nCorrect, getMaxData: useAllCorrectLetters,
                                        useJourney: useJourneyForLetters));

            var wrongAnswers = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetLettersNotIn(parameters.letterFilters, wordLetters.ToArray()),
                new SelectionParameters(parameters.wrongSeverity, nWrong, useJourney: parameters.useJourneyForWrong));

            if (ConfigAI.verboseTeacher)
            {
                string debugString = "--------- TEACHER: question pack result ---------";
                debugString += "\nQuestion: " + question;
                debugString += "\nCorrect Answers: " + correctAnswers.Count;
                foreach (var l in correctAnswers)
                {
                    debugString += " " + l;
                }
                debugString += "\nWrong Answers: " + wrongAnswers.Count;
                foreach (var l in wrongAnswers)
                {
                    debugString += " " + l;
                }
                UnityEngine.Debug.Log(debugString);
            }

            return(QuestionPackData.Create(question, correctAnswers, wrongAnswers));
        }
示例#9
0
        private QuestionPackData CreateSingleQuestionPackData()
        {
            var teacher = AppManager.I.Teacher;

            // Get a question phrase at random
            int nToUse        = 1;
            var usablePhrases = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetPhrasesByCategory(Db.PhraseDataCategory.Question, parameters.wordFilters, parameters.phraseFilters),
                new SelectionParameters(parameters.correctSeverity, nToUse, useJourney: parameters.useJourneyForCorrect,
                                        packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs));
            var question = usablePhrases[0];

            // Get the linked reply phrase
            var reply = teacher.wordHelper.GetLinkedPhraseOf(question);

            var correctAnswers = new List <Db.PhraseData>();

            correctAnswers.Add(reply);

            // Get random wrong phrases
            var wrongPhrases = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetPhrasesNotIn(parameters.wordFilters, parameters.phraseFilters, question, reply),
                new SelectionParameters(parameters.correctSeverity, nWrong, useJourney: parameters.useJourneyForWrong,
                                        packListHistory: parameters.wrongChoicesHistory, filteringIds: previousPacksIDs));

            if (ConfigAI.verboseTeacher)
            {
                string debugString = "--------- TEACHER: question pack result ---------";
                debugString += "\nQuestion: " + question;
                debugString += "\nCorrect Answers: " + correctAnswers.Count;
                foreach (var l in correctAnswers)
                {
                    debugString += " " + l;
                }
                debugString += "\nWrong Answers: " + wrongPhrases.Count;
                foreach (var l in wrongPhrases)
                {
                    debugString += " " + l;
                }
                UnityEngine.Debug.Log(debugString);
            }

            return(QuestionPackData.Create(question, correctAnswers, wrongPhrases));
        }
示例#10
0
        private QuestionPackData CreateSingleQuestionPackData()
        {
            var teacher = AppManager.I.Teacher;

            // Get a letter
            var usableLetters = teacher.wordAI.SelectData(
                () => FindEligibleLetters(atLeastNWords: nCorrect),
                new SelectionParameters(parameters.correctSeverity, 1, useJourney: parameters.useJourneyForCorrect,
                                        packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs_letters));
            var commonLetter = usableLetters[0];

            // Get words with the letter
            var correctWords = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetWordsWithLetter(parameters.wordFilters, commonLetter.Id),
                new SelectionParameters(parameters.correctSeverity, nCorrect, useJourney: parameters.useJourneyForCorrect,
                                        packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs_words));

            // Get words without the letter
            var wrongWords = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetWordsNotIn(parameters.wordFilters, correctWords.ToArray()),
                new SelectionParameters(parameters.wrongSeverity, nWrong, useJourney: parameters.useJourneyForWrong));

            var pack = QuestionPackData.Create(commonLetter, correctWords, wrongWords);

            if (ConfigAI.verboseTeacher)
            {
                string debugString = "--------- TEACHER: question pack result ---------";
                debugString += "\nQuestion: " + commonLetter;
                debugString += "\nCorrect Answers: " + correctWords.Count;
                foreach (var l in correctWords)
                {
                    debugString += " " + l;
                }
                debugString += "\nWrong Answers: " + wrongWords.Count;
                foreach (var l in wrongWords)
                {
                    debugString += " " + l;
                }
                UnityEngine.Debug.Log(debugString);
            }

            return(pack);
        }
        private QuestionPackData CreateSingleQuestionPackData()
        {
            var teacher = AppManager.I.Teacher;

            var correctLetters = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetAllLetters(parameters.letterFilters),
                new SelectionParameters(parameters.correctSeverity, nCorrect, useJourney: parameters.useJourneyForCorrect,
                                        packListHistory: parameters.correctChoicesHistory, filteringIds: previousPacksIDs)
                );

            var wrongLetters = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetLettersNotIn(parameters.letterFilters, correctLetters.ToArray()),
                new SelectionParameters(parameters.wrongSeverity, nWrong, useJourney: parameters.useJourneyForWrong,
                                        packListHistory: parameters.wrongChoicesHistory, filteringIds: previousPacksIDs)
                );

            var question = firstCorrectIsQuestion ? correctLetters[0] : null;

            if (ConfigAI.verboseTeacher)
            {
                string debugString = "--------- TEACHER: question pack result ---------";
                debugString += "\nCorrect Letters: " + correctLetters.Count;
                foreach (var l in correctLetters)
                {
                    debugString += " " + l;
                }
                debugString += "\nWrong Letters: " + wrongLetters.Count;
                foreach (var l in wrongLetters)
                {
                    debugString += " " + l;
                }
                UnityEngine.Debug.Log(debugString);
            }

            return(QuestionPackData.Create(question, correctLetters, wrongLetters));
        }
示例#12
0
        public List <QuestionPackData> CreateAllQuestionPacks()
        {
            List <QuestionPackData> packs = new List <QuestionPackData>();
            var teacher = AppManager.I.Teacher;

            var db      = AppManager.I.DB;
            var choice1 = db.GetWordDataById("consonant");
            var choice2 = db.GetWordDataById("vowel");

            int nPerType = nPacks / 2;

            var list_choice1 = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetConsonantLetter(parameters.letterFilters),
                new SelectionParameters(parameters.correctSeverity, nPerType, useJourney: parameters.useJourneyForCorrect)
                );

            var list_choice2 = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetVowelLetter(parameters.letterFilters),
                new SelectionParameters(parameters.correctSeverity, nPerType, useJourney: parameters.useJourneyForCorrect)
                );

            foreach (var data in list_choice1)
            {
                var correctWords = new List <Db.WordData>();
                var wrongWords   = new List <Db.WordData>();
                correctWords.Add(choice1);
                wrongWords.Add(choice2);

                var pack = QuestionPackData.Create(data, correctWords, wrongWords);
                packs.Add(pack);
            }

            foreach (var data in list_choice2)
            {
                var correctWords = new List <Db.WordData>();
                var wrongWords   = new List <Db.WordData>();
                correctWords.Add(choice2);
                wrongWords.Add(choice1);

                var pack = QuestionPackData.Create(data, correctWords, wrongWords);
                packs.Add(pack);
            }


            // Shuffle the packs at the end
            packs = packs.Shuffle();

            if (ConfigAI.verboseTeacher)
            {
                foreach (var pack in packs)
                {
                    string debugString = "--------- TEACHER: question pack result ---------";
                    debugString += "\nQuestion: " + pack.question;
                    debugString += "\nCorrect Word: " + pack.correctAnswers.Count;
                    foreach (var l in pack.correctAnswers)
                    {
                        debugString += " " + l;
                    }
                    debugString += "\nWrong Word: " + pack.wrongAnswers.Count;
                    foreach (var l in pack.wrongAnswers)
                    {
                        debugString += " " + l;
                    }
                    UnityEngine.Debug.Log(debugString);
                }
            }

            return(packs);
        }
示例#13
0
        private QuestionPackData CreateSingleQuestionPackData()
        {
            QuestionPackData pack = null;
            var teacher           = AppManager.I.Teacher;

            // @note this specific builder works differently, because we first need to get words and then their letters
            // this is a special case because the focus in both on words and on letters
            // we should try to modify it to mimic the rest of the system, i.e. by first selecting letters, and only then selecting words
            // however, we cannot do so easily, as we cannot just get words that 'contain letters that may be common'
            // instead, I should just count common letters, and then select these letters that appear more than nWords*nPacks times

            // Get all words
            var usableWords = teacher.wordAI.SelectData(
                () => teacher.wordHelper.GetAllWords(parameters.wordFilters),
                new SelectionParameters(parameters.correctSeverity, getMaxData: true, useJourney: parameters.useJourneyForCorrect));

            int  nAttempts = 100;
            bool found     = false;

            while (nAttempts > 0 && !found)
            {
                var wordsToUse    = usableWords.RandomSelect(nWords);
                var commonLetters = teacher.wordHelper.GetCommonLettersInWords(wordsToUse.ToArray());
                //UnityEngine.Debug.Log("Trying letters: " + commonLetters.Count);
                if (commonLetters.Count < nMinCommonLetters || commonLetters.Count > nMaxCommonLetters)
                {
                    nAttempts--;
                    continue;
                }

                var nonCommonLetters = teacher.wordHelper.GetLettersNotIn(parameters.letterFilters, commonLetters.ToArray()).RandomSelect(nWrong);

                // Debug
                if (ConfigAI.verboseTeacher)
                {
                    string debugString = "--------- TEACHER: question pack result ---------";
                    debugString += "\nCommon letters: ";
                    foreach (var l in commonLetters)
                    {
                        debugString += " " + l;
                    }
                    foreach (var word in wordsToUse)
                    {
                        debugString += "\nWord: " + word;
                        foreach (var l in word.Letters)
                        {
                            debugString += " " + l;
                        }
                    }
                    UnityEngine.Debug.Log(debugString);
                }

                pack  = QuestionPackData.Create(wordsToUse, commonLetters, nonCommonLetters);
                found = true;
            }

            if (!found)
            {
                throw new System.Exception("Could not find enough data to prepare the CommonLettersInWordQuestionBuilder. (Special behaviour)");
            }

            return(pack);
        }