Пример #1
0
        public static string GetSentenceToQuestion(IQuest quest)
        {
            var sens = quest.GetSentences();

            if (sens.Any())
            {
                Console.WriteLine("Sen got on DB.");
            }
            else if (!sens.Any())
            {
                var url = quest.ToLudwigUrl();
                TryToGetSentencesOnThisSite(quest, sens, url);

                if (sens.Any())
                {
                    Console.WriteLine("Sen got on Ludwig.");
                }

                if (!sens.Any() && !quest.Text.Contains(' '))
                {
                    url = quest.ToBritannicaUrl();
                    TryToGetSentencesOnThisSite(quest, sens, url);

                    if (sens.Any())
                    {
                        Console.WriteLine("Sen got on Britannica.");
                    }
                }

                if (!sens.Any())
                {
                    Console.WriteLine("Sen not found. URL: " + url);
                    return(quest.Text);
                }
            }

            var chosen = sens.PickRandom();

            return(chosen);
        }