Visual Studio C# 语法/句子结构检查方法

Jor*_*ers 2 c# parsing visual-studio

我正在使用C#Visual Studio中。我需要一个对象,我可以向它发送一个包含英语句子的字符串。我需要对象有一个方法来告诉我我的英语句子是否有任何grammar/structure errors.

想想 MS Word 中的拼写/语法检查器。任何grammar/structure errors将用绿线下划线。我需要确定任何用 MS Word 编写的任意句子是否会有绿色下划线。

如果存在这样的东西,它可能看起来像这样:

checkGrammar("Arbitrary sentence");   //returns true/false based on being      correct or not.
Run Code Online (Sandbox Code Playgroud)

我一直在寻找这样的东西,但我所有的搜索工作都由Visual Studio Spell Checker的结果主导,它检查您的实际代码......不是我需要的。

有谁知道 C# 中是否存在这样的东西?

在此先感谢您的帮助。

Bra*_*ner 5

如果您可以确定它会安装在运行该程序的计算机上,则您可以在语法上使用 Word 的语法检查器。

文档

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

return word.CheckGrammar("String to check");
Run Code Online (Sandbox Code Playgroud)