public async Task <IEnumerable <SimilarWord> > FindRelatedTriggeres(string searchWord)
        {
            logger.LogInformation("Find words realted to: " + searchWord);

            var result = await wordFinderService.GetRelatedTriggerWords(searchWord);

            return(result.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// Finds related words for <param name="searchTerm"/> limiting the results based on the criteria set in config.
        /// All scores are normalised against the minimum accepted score.
        /// </summary>
        /// <param name="searchTerm">Term to search for.</param>
        /// <returns>Top results related to search term.</returns>
        private async Task <List <SimilarWord> > FindTopRelatedWordsFor(string searchTerm)
        {
            int minScore   = emojiRelatedWordOptions?.Value?.MinScoreForRelatedWords ?? 1;
            var foundWords = await wordFinderService.GetRelatedTriggerWords(searchTerm);

            var topResults = foundWords
                             .Where(x => x.Score >= minScore)
                             .OrderByDescending(s => s.Score)
                             .Take(emojiRelatedWordOptions?.Value?.MaxAmountRelatedWords ?? NUMBER_OF_RELATED_WORDS_TO_SAVE)
                             .ToList();

            foreach (var relatedWord in topResults)
            {
                relatedWord.Type  = SimilarWordType.RELATED;
                relatedWord.Score = (relatedWord.Score * 100) / minScore;
            }

            return(topResults);
        }