4

I'm working with C# in Visual Studio. I need an object to which I can send a String containing an English sentence. I need the object to have a method that will tell me if my English sentence has any grammar/structure errors.

Think of the spell/grammar checker in MS Word. Any grammar/structure errors will be underlined by a green line. I need to determine if any arbitrary sentence would have a green underline if it were written in MS Word.

If such a thing exists it may look like this:

checkGrammar("Arbitrary sentence");   //returns true/false based on being      correct or not.

I have looked for something like this but all my search efforts are dominated by results for a Visual Studio Spell Checker which checks your actual code....not what I need.

Does anyone know if such a thing exists in C#?

Thanks in advance for any help.

Iamat8
  • 3,888
  • 9
  • 25
  • 35
  • Visual Studio isn't a programming language, try "C# Spell Checker" https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=c%23%20spell%20checker – Ron Beyer Oct 12 '15 at 17:55
  • 2
    The linked "duplicate" is NOT a duplicate of this question. it only deals with spellcheck and is specific to winforms. – Bradley Uffner Oct 12 '15 at 18:06
  • @BradleyUffner The OP states `would have a green underline`, which sounds like they're using WinForms or WPF, and one of the answers to the duplicate target detail how to use these functions elsewhere (e.g, WPF). – AStopher Oct 12 '15 at 18:11
  • @AStopher, it's still NOT a duplicate, as it only mentions spelling and this is specific to spelling AND grammar. – BrainSlugs83 Jul 27 '20 at 20:31
  • @BrainSlugs83 Really not sure why you're pinging me about a comment I wrote almost five years ago, but one of the answers on the duplicate target _did_ detail (or still does, I haven't checked) how to use those functions elsewhere. I never implied the question was a duplicate, simply that one of the answers in the duplicate target might be helpful. – AStopher Jul 28 '20 at 21:05
  • @AStopher Ahh, apologies, I wasn't looking at the dates. – BrainSlugs83 Jul 31 '20 at 01:56

1 Answers1

6

You may be able to use Word's Grammar checker grammatically if you can be sure it will be installed on the computer running the program.

Documentation

Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();

return word.CheckGrammar("String to check");
Bradley Uffner
  • 16,641
  • 3
  • 39
  • 76