Esempio n. 1
0
        private static void getKnownAnagrams(string[] args)
        {
            DictionaryFileReader reader = new DictionaryFileReader(GetConfiguration().Build());

            if (args[1] == "" || args[1] == null)
            {
                Console.WriteLine("Please add a word the the query");
            }
            var anagramCheckerDictionary = new AnagramCheckerDictionary(reader);
            var knownWords = anagramCheckerDictionary.getKnown(args[1]).Result.ToList();

            if (knownWords.Count == 0)
            {
                Console.WriteLine(args[1] + " not Found");
            }
            string words = "";

            foreach (string kWord in knownWords)
            {
                if (kWord != args[1])
                {
                    words += kWord + ", ";
                }
            }
            Console.WriteLine("Known Anagrams: " + words);
        }
        public IActionResult GetKnownWords([FromQuery] string word)
        {
            if (word == "" || word == null)
            {
                return(NotFound("Please add a word the the query"));
            }
            var anagramCheckerDictionary = new AnagramCheckerDictionary(reader);
            var knownWords = anagramCheckerDictionary.getKnown(word).Result;

            if (knownWords.Count() == 0)
            {
                logger.LogWarning("No Anagram found");
                return(NotFound(word + " not Found"));
            }
            string words = "";

            foreach (string kWord in knownWords)
            {
                if (kWord != word)
                {
                    words += kWord + ", ";
                }
            }
            return(Ok("Known Anagrams: " + words));
            //return NotFound("");
        }