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 OpenAI generative models. 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-.NET.git. | |
Document doc = new Document(MyDir + "Big document.docx"); | |
string apiKey = Environment.GetEnvironmentVariable("API_KEY"); | |
// Use OpenAI generative language models. | |
IAiModelText model = (IAiModelText)AiModel.Create(AiModelType.Gpt4OMini).WithApiKey(apiKey); | |
CheckGrammarOptions grammarOptions = new CheckGrammarOptions(); | |
grammarOptions.ImproveStylistics = true; | |
Document proofedDoc = model.CheckGrammar(doc, grammarOptions); | |
proofedDoc.Save("AI.AiGrammar.docx"); |