C# 如何使用Microsoft Word Automation语法分析句子

C# 如何使用Microsoft Word Automation语法分析句子,c#,parsing,vba,ms-word,office-automation,C#,Parsing,Vba,Ms Word,Office Automation,我编写了一些代码,根据以下URL中的建议解析Microsoft Word文档中的句子: 我编写了一个小函数,用于读取文档并通过调试语句输出其语句: using Microsoft.Office.Interop.Word; private void button2_Click(object sender, EventArgs e) { oWord.Visible = true; object filename = textBox1.Text; oDoc =

我编写了一些代码,根据以下URL中的建议解析Microsoft Word文档中的句子:

我编写了一个小函数,用于读取文档并通过调试语句输出其语句:

using Microsoft.Office.Interop.Word;


private void button2_Click(object sender, EventArgs e)
    {
    oWord.Visible = true;

    object filename = textBox1.Text;

    oDoc = oWord.Documents.Open(filename, ref oMissing, true, false, ref oMissing, ref oMissing, ref oMissing,
        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

    Sentences sentences;

    sentences = oDoc.Sentences;

    Debug.WriteLine("sentences=" + sentences.ToString());

    foreach (Range r in sentences)
    {
        Debug.WriteLine("range.Text=" + r.Text);
    }
}

它所做的工作和我之前在字符串上使用Mid函数所做的一样好。考虑到MS Word具有语法检查功能,我希望它能做得更好。有什么方法可以利用MS Word的语法能力,使其在句子分析方面更加智能?

你的标题有点让人困惑。考虑将语法添加到标题。好的,我按要求修改了我的标题。我用Idooptho做了很多工作,主要是W/Excel,而且我没有看到任何方法来完成你要问的。也许另一种编辑方法是给出一个您试图解析的示例,以便查看它如何与您当前的代码不兼容。也许有另一种方法。由句子对象返回的范围对象不够聪明,无法解析缩写。有时,当我使用感叹号和疑问时,返回的范围为空,下一个范围对象返回文档中的后续句子。我只是希望Word比这更聪明。顺便说一句,我希望使用Word来快速而肮脏的解决方案,而不必使用真正的自然语言解析器。否则,我将返回到我的简单解析并手动处理它。