CheckGrammar

IAiModelText.CheckGrammar method

Checks grammar of the provided document. This operation leverages the connected AI model for checking grammar of document.

public Document CheckGrammar(Document sourceDocument, CheckGrammarOptions options = null)
ParameterTypeDescription
sourceDocumentDocumentThe document being checked for grammar.
optionsCheckGrammarOptionsOptional settings to control how grammar will be checked.

Return Value

A new Document with checked grammar.

Examples

Shows how to check the grammar of a document.

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");

See Also