private void Button2_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBox1.Text)) { MessageBox.Show("Write your word, please."); } else { tb2_viewRes.Text = ""; IEnumerable <string> synonyms = thesaurus.GetSynonyms(textBox1.Text.Trim()); foreach (var item in synonyms) { if (!string.IsNullOrWhiteSpace(item)) { tb2_viewRes.Text += item + Environment.NewLine; } } if (string.IsNullOrWhiteSpace(tb2_viewRes.Text.Trim().Replace(Environment.NewLine, ""))) { tb2_viewRes.Text = $"{Environment.NewLine}= SYNONYMS ={Environment.NewLine}= NOT FOUND ="; } } }
private void ListSynonymsForWord() { Console.WriteLine("Input the word you want the synonyms of:"); string word = Console.ReadLine(); Console.Clear(); var synonyms = thesaurus.GetSynonyms(word); if (synonyms.Any()) { Console.WriteLine("Synonyms for '{0}' are:", word); foreach (string synonym in synonyms) { Console.WriteLine(synonym); } } else { Console.WriteLine("The word '{0}' doesn't have any synonyms", word); } Console.ReadKey(); }
public IEnumerable <string> Get(string synonym) { return(thesaurusService.GetSynonyms(synonym)); }
private void AssertNonExistingWord(String word) { var words = thesaurus.GetSynonyms(word).ToList(); Assert.IsTrue(!words.Any()); }
public void QueryPopolarWords() { Assert.IsTrue(thesaurus.GetSynonyms("red").Any()); Assert.IsTrue(thesaurus.GetSynonyms("black").Any()); Assert.IsTrue(thesaurus.GetSynonyms("peach").Any()); Assert.IsTrue(thesaurus.GetSynonyms("house").Any()); Assert.IsTrue(thesaurus.GetSynonyms("dictionary").Any()); Assert.IsTrue(thesaurus.GetSynonyms("need").Any()); Assert.IsTrue(thesaurus.GetSynonyms("sand").Any()); Assert.IsTrue(thesaurus.GetSynonyms("monkey").Any()); }