Get synonym list of given word or phrase using C#.Net
This code snippet returns list of all synonyms for the given word or phrase. I use word DLL to get these synonyms.
Some time we asked for synonyms for a particular word then we use dictionary but if you need to integrate with application then it is cumbersome. this method gets string and return list of synonyms, if it found synonyms else list length would be zero. This method opens a word application and gets all synonyms for that word. It is very similar to open a word document write that word and get synonyms list after right click. For example if you pass string (Word) “Document" then this method return all synonyms list “text, file, article, essay, paper, etc.
private List<string> GetSynonyms(string SearchText)
{
private ApplicationClass wordApp = new ApplicationClass();
List<string> searchList = new List<string>();
WriteLogger("Inside GetSynonyms");
try
{
object languageID = Word.WdLanguageID.wdEnglishAUS;
//Get all Synonyms of given word
SynonymInfo synInfo = WordApp.get_SynonymInfo(SearchText, ref languageID);
Array objSynInfo = synInfo.MeaningList as Array;
//Add all synonyms to search list
WriteLogger(objSynInfo.Length + " Synonyms Found");
for (int synCount = 1; synCount <= objSynInfo.Length; synCount++)
{
SearchList.Add(objSynInfo.GetValue(synCount).ToString());
}
}
catch
{
WriteLogger("Error while getting synonyms");
}
return SearchList;
}
can you tell me which namespace and assembly I have to add to use this code....