Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if word in english dictionary programmatically in c#

I want to check if a word is in English dictionary and make it a tag. All i know is that NetSpell has a dll but i don't know how to check it.

like image 303
Amarnauth Persaud Avatar asked May 14 '11 18:05

Amarnauth Persaud


People also ask

How to check whether a word is in the English Dictionary?

Step-1: Import enchant. The enchant is a module that checks for the spelling therefore we need to import it. Step-3: Then by using the check method in enchant check whether the word is in the English dictionary or not, if the word is in the English dictionary it returns true, or else it returns false.

How to programmatically check spelling in a document?

How to: Programmatically check spelling in documents. To check the spelling in a document, use the CheckSpelling method. This method returns a Boolean value that indicates whether the supplied parameter is spelled correctly. Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word.

What is a dictionary search program?

A program that searches for a word in a dictionary. - Create a small dictionary of strings - Not in order - Create an interface for user to search for a word in the dictionary If the word is not found, the word is added to the dictionary.

What is dictionary in C with examples?

C# Dictionary with examples. In C#, Dictionary is a generic collection which is generally used to store key/value pairs. The working of Dictionary is quite similar to the non-generic hashtable. The advantage of Dictionary is, it is generic type. Dictionary is defined under System.Collection.Generic namespace.


1 Answers

This is the solution:

NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary(); 

oDict.DictionaryFile = "en-US.dic"; 
//load and initialize the dictionary 
oDict.Initialize();
string txtWords = Company;
NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling(); 

oSpell.Dictionary = oDict; 
char []chDelims = {' ','\n', '\t', '\r'};
foreach (string s in txtWords.Split(chDelims)) 
{ 
    if (s.Length > 0 && oSpell.TestWord(s)) 
    { 
        //Do something here...
    } 
} 
like image 160
Amarnauth Persaud Avatar answered Sep 30 '22 06:09

Amarnauth Persaud