To import synonyms from a file, use the ImportDictionary method.
The following example demonstrates the use of methods of the synonym dictionary.
C#
stringindexFolder=@"c:\MyIndex\";// Creating an index from in specified folderIndexindex=newIndex(indexFolder);// Getting synonyms for word 'make'string[]synonyms=index.Dictionaries.SynonymDictionary.GetSynonyms("make");Console.WriteLine("Synonyms for 'make':");for(inti=0;i<synonyms.Length;i++){Console.WriteLine(synonyms[i]);}// Getting groups of synonyms to which word 'make' belongs tostring[][]groups=index.Dictionaries.SynonymDictionary.GetSynonymGroups("make");Console.WriteLine("Synonym groups for 'make':");for(inti=0;i<groups.Length;i++){string[]group=groups[i];for(intj=0;j<group.Length;j++){Console.Write(group[j]+" ");}Console.WriteLine();}if(index.Dictionaries.SynonymDictionary.Count>0){// Removing all synonyms from the dictionaryindex.Dictionaries.SynonymDictionary.Clear();}// Adding synonyms to the dictionarystring[][]synonymGroups=newstring[][]{newstring[]{"achieve","accomplish","attain","reach"},newstring[]{"accept","take","have"},};index.Dictionaries.SynonymDictionary.AddRange(synonymGroups);// Export synonyms to a fileindex.Dictionaries.SynonymDictionary.ExportDictionary(@"C:\Synonyms.dat");// Import synonyms from a fileindex.Dictionaries.SynonymDictionary.ImportDictionary(@"C:\Synonyms.dat");
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: