Example #1
0
        public static Dictionary <string, List <string> > FormatMatches(string VocabWord)
        {
            var           allMatches = VocabMatch.GetMatches(VocabWord);
            List <string> synonyms   = new List <string>();
            Regex         rgx        = new Regex("[^a-zA-Z0-9 -]");
            string        replacer   = ", ";
            Dictionary <String, List <string> > formattedMatches = new Dictionary <String, List <string> >();

            foreach (var list in allMatches)
            {
                var formattedSynonyms = rgx.Replace(list.list.synonyms, replacer);
                formattedSynonyms = formattedSynonyms.Replace("similar term,", "").Replace("related term,", "").Replace("antonym,", "");
                var synonymString = formattedSynonyms.ToString();
                var finalFormat   = synonymString.Split(',');
                Console.WriteLine(finalFormat);
                foreach (var synonym in finalFormat)
                {
                    if (!string.IsNullOrWhiteSpace(synonym))
                    {
                        synonyms.Add(synonym);
                    }
                }
            }

            formattedMatches.Add(VocabWord, synonyms);
            Console.WriteLine(formattedMatches);
            return(formattedMatches);
        }
Example #2
0
        public static List <Dictionary <string, List <string> > > GetMatchList(VocabWordList wordList)
        {
            List <Dictionary <string, List <string> > > result = new List <Dictionary <string, List <string> > >();
            List <string> words = new List <string>()
            {
                wordList.Word1,
                wordList.Word2,
                wordList.Word3,
                wordList.Word4
            };

            foreach (var word in words)
            {
                var match = VocabMatch.FormatMatches(word);
                result.Add(match);
            }

            return(result);
        }