Grammar Checking

Contents
[ ]

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 Anthropic 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:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Node.js-via-.NET.git.
let doc = new aw.Document(base.myDir + "Big document.docx");
const apiKey = process.env.API_KEY;
if (!apiKey) {
console.warn("API_KEY environment variable is not set.");
return;
}
// Use OpenAI generative language models.
let model = aw.AI.AiModel.createGpt4OMini();
model.setApiKey(apiKey);
let grammarOptions = new aw.AI.CheckGrammarOptions();
grammarOptions.improveStylistics = true;
let proofedDoc = model.checkGrammar(doc, grammarOptions);
proofedDoc.save(base.artifactsDir + "AI.AiGrammar.docx");
view raw ai-grammar.js hosted with ❤ by GitHub