locked
Grammer and spell check in c# RRS feed

  • Question

  • User-257070954 posted

    Hi All,

              Please help me to implement Grammer and spellcheck feature  in c# web application. Is there any third party library available. If available how implement in c#?

    Monday, January 25, 2021 2:22 AM

Answers

  • User-939850651 posted

    Hi binustrat,

    If you want to implement sentence grammar or spell checking, you can use ApplicationClass in Microsoft.Office.Interop.Word Namespace.

    The CheckGrammar(string param) and CheckSpelling(string param) functions are used to check grammar and spelling respectively.

    A simple demo:

    Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
                string statement1 = "Here is a test example.";
                string statement2 = "Here is a test exmple.";
                string statement3 = "Here is the a test example.";
                bool v1 = word.CheckGrammar(statement1);
                bool v2 = word.CheckSpelling(statement1);
                Console.WriteLine("Statement 1 has"+(v1 ? " no " :" " ) + "grammatical problem.");
                Console.WriteLine("Sentence 1 has"+ (v2 ? " no " : " ") + "spelling problem.");
                Console.WriteLine();
                bool v3 = word.CheckGrammar(statement2);
                bool v4 = word.CheckSpelling(statement2);
                Console.WriteLine("Statement 2 has" + (v3 ? " no " : " ") + "grammatical problem.");
                Console.WriteLine("Sentence 2 has" + (v4 ? " no " : " ") + "spelling problem.");
    Console.WriteLine(); bool v5 = word.CheckGrammar(statement3); bool v6 = word.CheckSpelling(statement3); Console.WriteLine("Statement 3 has" + (v5 ? " no " : " ") + "grammatical problem."); Console.WriteLine("Sentence 3 has" + (v6 ? " no " : " ") + "spelling problem."); Console.ReadLine();

    Result:

    Hope this can help you.

    Best regards,

    Xudong Peng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 26, 2021 6:13 AM