本文整理汇总了C#中Microsoft.Office.Interop.Word.Application.CheckGrammar方法的典型用法代码示例。如果您正苦于以下问题:C# Application.CheckGrammar方法的具体用法?C# Application.CheckGrammar怎么用?C# Application.CheckGrammar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Word.Application
的用法示例。
在下文中一共展示了Application.CheckGrammar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateMarks
/// <summary>
/// It evaluates the responses provided by the student with the responses given by a instructor to grade a test using two separate XMLs.
/// MCQs and Fill in the blanks type of questions are graded by comparing the responses, while Essay question is graded based on the
/// number of keywords or their synonyms used, grammatical errors, spellcheck, word limit and paragraphs.
/// </summary>
private void CalculateMarks()
{
XmlSerializer ser = new XmlSerializer(typeof(Test));
finalTest = ser.Deserialize(new FileStream("D:\\test.xml", FileMode.Open)) as Test;
totalQuestions = test.Question.Count();
ser = new XmlSerializer(typeof(TestAnswers));
finalTestAnswer = ser.Deserialize(new FileStream("D:\\StudentResponse.xml", FileMode.Open)) as TestAnswers;
List<TestQuestion> quesList = new List<TestQuestion>();
for (int i = 0; i < totalQuestions; i++)
{
quesList.Add(finalTest.Question[i]);
}
int j = 0;
double essayMarks = 100.0f;
foreach (var question in quesList)
{
if (question.Type == QuesTypeVal.MCQ.ToString())
{
if (question.Option1.Answer == "Yes" && question.Option1.Value == finalTestAnswer.Answer[j].Value)
{
marks += 5;
}
else if (question.Option2.Answer == "Yes" && question.Option2.Value == finalTestAnswer.Answer[j].Value)
{
marks += 5;
}
else if (question.Option3.Answer == "Yes" && question.Option3.Value == finalTestAnswer.Answer[j].Value)
{
marks += 5;
}
else if (question.Option4.Answer == "Yes" && question.Option4.Value == finalTestAnswer.Answer[j].Value)
{
marks += 5;
}
j++;
}
else if (question.Type == QuesTypeVal.Text.ToString())
{
if (question.Answer.Text == finalTestAnswer.Answer[j].Value)
{
marks += 5;
}
j++;
}
else if (question.Type == QuesTypeVal.EssayText.ToString())
{
string essayResponse = finalTestAnswer.Answer[j].Value;
int nKeyword = question.Answer.Keyword.Count();
double keywordMark = 40.0 / (double)nKeyword;
int checkSynonym = 0;
double wordMarks = 0.0f;
List<string> essayList = new List<string>();
var essayString = Regex.Split(essayResponse, @"[\n]+");
int noParagraphs = essayString.Count();
bool nParaCorrect = false;
for (int i = 0; i < noParagraphs; i++)
{
if (essayString[i] != string.Empty)
essayList.Add(essayString[i]);
}
if (essayList.Count() != question.NumberOfParagraphs)
{
essayMarks = 20;
}
else
{
List<string> wordList = new List<string>();
foreach (string essayPara in essayList)
{
var s = Regex.Split(essayPara, @"[,\s\n]+");
foreach (string k in s)
{
wordList.Add(k);
}
}
if (wordList.Count >= question.TotalNumberOfWords)
{
essayMarks = 20;
}
else
{
bool grammarCheck = true;
Microsoft.Office.Interop.Word.Application myWord = new Microsoft.Office.Interop.Word.Application();
foreach (string essay in essayList)
{
grammarCheck = myWord.CheckGrammar(essay);
if (!grammarCheck)
{
essayMarks -= 5;
}
}
//.........这里部分代码省略.........