Пример #1
0
        /// <inheritdoc/>
        public async Task <SweatTestResult> SweatTest(string parentWord, string injectWord, string providedAnswer)
        {
            providedAnswer = providedAnswer.ToLower();
            SweatTestResult result = new SweatTestResult();

            var foundOptions = await mergeService.MergeWords(
                parentWord,
                injectWord,
                ResultSet.ALL_RESULTS,
                SynonymsOfInjectWord.INCLUDE,
                SynonymsOfParentWord.EXCLUDE
                );

            NormaliseScores(foundOptions);

            result.Alternatives = foundOptions.Where(x => x.Word != providedAnswer).ToList();
            var foundAnswers = foundOptions.Where(x => x.Word == providedAnswer);

            if (foundAnswers?.Count() > 0)
            {
                result.Score   = foundAnswers.First().Score;
                result.Outcome = DetermineSweatLevels(foundOptions, foundAnswers.First());
            }

            logger.LogInformation("SweatTest of '" + providedAnswer + "' has score: " + result.Score);

            return(result);
        }
Пример #2
0
        public async Task <IEnumerable <SimilarWord> > FindMerge(string parentWord, string injectWord)
        {
            logger.LogInformation("Find merged words for '" + parentWord + "' and '" + injectWord + "'");

            var result = await mergeService.MergeWords(parentWord, injectWord);

            return(result.ToArray());
        }