Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
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");
}
Q: Which AI models can be used with CheckGrammar?
A: The AiModelType enumeration includes OpenAI (e.g., GPT‑4o mini), Google (Gemini), and Anthropic Claude families. Choose the model that fits your needs and create it via AiModel::Create.
Q: How do I provide the API key for the selected AI model?
A: After creating the model instance, call WithApiKey(u"YOUR_API_KEY") on the AiModel object, as shown in the code example. The key must be valid for the chosen provider.
Q: Do I need an additional license to use the AI features in Aspose.Words for C++?
A: No separate license is required; the AI functionality is part of the standard Aspose.Words for C++ library. However, you must have a valid subscription for the external AI service (OpenAI, Google, etc.) whose API you are calling.
Q: Can I improve the stylistic suggestions returned by CheckGrammar?
A: Yes. Set CheckGrammarOptions::set_ImproveStylistics(true) to enable additional stylistic improvements beyond basic grammar corrections.
Q: What happens if the document is very large?
A: CheckGrammar processes the document in chunks internally, but extremely large files may increase latency or exceed provider request limits. Consider splitting the document or adjusting the provider’s request size settings if you encounter time‑outs.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.