文档 AI
该 Aspose.Words Document AI for .NET 插件允许开发者翻译或摘要文档并检查其语法。可与 Gemini、Claude 和 OpenAI 等大型语言模型集成。.
安装与设置
- 安装 Aspose.Words 用于 .NET 包 通过 NuGet 或包管理器控制台。.
- 配置计量授权 在运行邮件合并操作之前。.
兼容 Windows、Linux、macOS 和移动平台 使用 .NET 框架、.NET Core 或 Mono。支持的 IDE 包括 Visual Studio(2010–2026)、Xamarin 和 MonoDevelop 2.4+。.
IDE:: Visual Studio 2017–2026、JetBrains Rider、MonoDevelop。.
支持的模板/输出格式:: DOC、DOCX、RTF、DOT、DOTX、DOTM、DOCM、Word 2003 XML 和 Word 2007 XML。.
翻译文档
将您的文档翻译成以下列出的任意语言: 语言 枚举::
Document doc = new Document(MyDir + "Document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use Google generative language models.
AiModel model = AiModel.Create(AiModelType.GeminiFlashLatest).WithApiKey(apiKey);
Document translatedDoc = model.Translate(doc, Language.Arabic);
translatedDoc.Save(ArtifactsDir + "AI.AiTranslate.docx");摘要文档
生成文档摘要,指定其长度::
- VeryShort – 1-2 句子
- Short – 3-4 句子
- Medium – 5-6 句子
- Long – 7-10 句子
- VeryLong – 11-20 句子
Document firstDoc = new Document("Big document.docx");
Document secondDoc = new Document("Document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use OpenAI or Google generative language models.
AiModel model = ((OpenAiModel)AiModel.Create(AiModelType.Gpt4OMini).WithApiKey(apiKey)).WithOrganization("Organization").WithProject("Project");
SummarizeOptions options = new SummarizeOptions();
options.SummaryLength = SummaryLength.Short;
Document oneDocumentSummary = model.Summarize(firstDoc, options);
oneDocumentSummary.Save("AI.AiSummarize.One.docx");
options.SummaryLength = SummaryLength.Long;
Document multiDocumentSummary = model.Summarize(new Document[] { firstDoc, secondDoc }, options);
multiDocumentSummary.Save("AI.AiSummarize.Multi.docx");检查文档语法
检查语法并检测文档中的错误::
Document doc = new Document(MyDir + "Big document.docx");
string apiKey = Environment.GetEnvironmentVariable("API_KEY");
// Use OpenAI generative language models.
AiModel model = AiModel.Create(AiModelType.Gpt4OMini).WithApiKey(apiKey);
CheckGrammarOptions grammarOptions = new CheckGrammarOptions();
grammarOptions.ImproveStylistics = true;
Document proofedDoc = model.CheckGrammar(doc, grammarOptions);
proofedDoc.Save("AI.AiGrammar.docx");常见问题
- Q: 可以在 .NET 的 Document AI 中使用哪些文件格式?? 该 Aspose.Words Document AI for .NET 插件支持 DOC、DOCX、RTF、DOT、DOTX、DOTM、DOCM、Word 2003 XML 和 Word 2007 XML 格式。.
- Q: 我可以在 Aspose.Words Document AI for .NET 中使用哪些模型?? Document AI for .NET 可以与诸如 Gemini、Claude 和 OpenAI 等 LLM 集成。.