Grammar Checking
Checking grammar in documents is important to ensure clarity, professionalism, and accuracy. Well-written documents leave a positive impression and avoid misunderstandings. Grammar checks help identify and correct errors quickly, saving time and improving quality.
Aspose.Words allows users to check grammar and detect errors in documents using the OpenAI, Google, and Claude models' families listed in the AiModelType enumeration. Use the CheckGrammar method, available in the Aspose.Words.AI namespace. CheckGrammar analyzes the text in a document and highlights grammatical problems.
The following code example shows how to use the GPT-4o mini model in Aspose.Words to check grammar:
void AiGrammar()
{
auto doc = MakeObject<Document>(MyDir + u"Big document.docx");
SharedPtr<IAiModelText> model = System::ExplicitCast<OpenAiModel>(MakeObject<AiModel>()->Create(AiModelType::Gpt4OMini)->WithApiKey(u"API_KEY"));
auto grammarOptions = MakeObject<CheckGrammarOptions>();
grammarOptions->set_ImproveStylistics(true);
auto proofedDoc = model->CheckGrammar(doc, grammarOptions);
proofedDoc->Save(ArtifactsDir + u"AI.AiGrammar.docx");
}