语法纠错Grammar Check

AI 驱动的语法检查与自动纠错,覆盖 20+ 语言的拼写、语法、标点和用词错误。AI-powered grammar checking and auto-correction for 20+ languages. Covers spelling, syntax, punctuation, and word choice.

快速概览

Quick Overview

语法纠错 API 采用深度学习模型,可精准识别并修正 20+ 种语言的拼写、语法、标点和风格问题。返回每个错误的详细位置、类型、原文和建议纠正方案,支持自动纠错和仅返回建议两种模式。适用于写作辅助、英语学习、内容审校、在线编辑器集成等场景。The Grammar Check API uses deep learning to accurately identify and correct spelling, grammar, punctuation, and style issues across 20+ languages. Returns detailed position, type, original text, and suggested correction for each error. Supports auto-correction and suggestion-only modes. Ideal for writing assistance, English learning, content review, and online editor integration.

认证方式

Authentication

所有 API 请求需在 HTTP Header 中携带 Access Token 进行身份认证:All API requests must include an Access Token in the HTTP Header for authentication:

Authorization: Bearer YOUR_ACCESS_TOKEN

请前往 控制台 获取您的 Access Token。Get your Access Token from the Dashboard.

请求头

Request Headers

HeaderHeaderValue必填Required说明Description
AuthorizationBearer {token}requiredBearer 认证令牌Bearer authentication token
Content-Typeapplication/jsonrequired请求体格式为 JSONRequest body format is JSON

检查类型参考

Check Types Reference

类型Typecheck_types说明Description示例Example
拼写Spellingspelling检查单词拼写错误Detect misspelled wordsrecieve → receiverecieve → receive
语法Grammargrammar检查语法结构错误(主谓一致、时态等)Check grammar (agreement, tense, etc.)He go → He goesHe go → He goes
标点Punctuationpunctuation检查标点符号使用是否正确Check punctuation correctness你好。你好吗 → 你好,你好吗Let's eat Grandma → Let's eat, Grandma
风格Stylestyle检查措辞风格(冗余、被动语态、口语化等)Check style (redundancy, passive voice, informality)进行了一个决定 → 决定make a decision → decide
用词Word Choicewordiness检查冗长表达,建议更简洁的替代Detect wordy phrases, suggest concise alternatives由于...的原因 → 因为due to the fact that → because

请求端点

Endpoint

POST/v1/grammar

请求参数

Request Parameters

参数Parameter类型Type必填Required说明Description
textstringrequired待检查文本,最大 50,000 字符Text to check, max 50,000 characters
langstringoptional语言代码,如 en/zh/ja;不填则自动检测Language code, e.g. en/zh/ja; auto-detect if omitted
auto_correctbooleanoptional是否启用自动纠错,默认 false(仅返回建议)Enable auto-correction; default false (suggestions only)
check_typesstring[]optional检查类型筛选,支持 spelling/grammar/punctuation/style/wordiness,默认全部Filter check types; supports spelling/grammar/punctuation/style/wordiness; default all
severitystringoptional最低严重级别:info/warning/error,默认 warning(仅返回 warning 及以上级别)Minimum severity: info/warning/error; default warning
disable_rulesstring[]optional需要禁用的检查规则 ID 列表(如禁用牛津逗号检查)List of rule IDs to disable (e.g. disable Oxford comma check)
domainstringoptional文本领域:general/academic/business/casual,默认 generalText domain: general/academic/business/casual; default general

请求示例

Request Examples

curl -X POST https://api.itranslator.cc/v1/grammar \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Their is many reasons to choose our servise.",
    "lang": "en",
    "auto_correct": true
  }'

响应字段

Response Fields

字段Field类型Type说明Description
originalstring原始文本Original text
correctedstring|null纠正后的文本(auto_correct=true 时有值,否则为 null)Corrected text (set when auto_correct=true, else null)
issuesobject[]发现的问题列表,按出现位置排序List of issues found, sorted by position
issues_countinteger问题总数量Total number of issues
langstring检测到的语言代码Detected language code
quality_scorenumber整体文本质量评分 0~100(100 为无错误)Overall quality score 0~100 (100 = no errors)

Issue 字段说明

Issue Object Fields

字段Field类型Type说明Description
typestring问题类型:spelling/grammar/punctuation/style/wordinessIssue type: spelling/grammar/punctuation/style/wordiness
offsetinteger错误在原文中的起始位置(0 起始字符索引)Start position in original text (0-based char index)
lengthinteger错误片段的字符长度Character length of the error segment
wrongstring原文中的错误片段Incorrect text segment from original
correctstring建议的正确替换Suggested correct replacement
severitystring严重程度:info/warning/errorSeverity level: info/warning/error
messagestring人类可读的错误说明Human-readable error explanation
rule_idstring触发的检查规则 IDTriggered check rule ID

响应示例(自动纠错模式)

Response Example (Auto-correct Mode)

{
  "original": "Their is many reasons to choose our servise.",
  "corrected": "There are many reasons to choose our service.",
  "issues": [
    { "type": "grammar", "offset": 0, "length": 5, "wrong": "Their", "correct": "There",
      "severity": "error", "rule_id": "CONFUSED_WORDS",
      "message": "'Their' is a possessive pronoun. Use 'There' as the existential subject." },
    { "type": "grammar", "offset": 6, "length": 2, "wrong": "is", "correct": "are",
      "severity": "error", "rule_id": "SUBJECT_VERB_AGREEMENT",
      "message": "Subject-verb agreement: 'many reasons' requires plural 'are'." },
    { "type": "spelling", "offset": 43, "length": 7, "wrong": "servise", "correct": "service",
      "severity": "error", "rule_id": "SPELLING",
      "message": "Spelling error." }
  ],
  "issues_count": 3,
  "lang": "en",
  "quality_score": 42
}

响应示例(仅建议模式)

Response Example (Suggestion-only Mode)

{
  "original": "我昨天去了图书馆,看了一本很有趣的书然后我去了咖啡馆。",
  "corrected": null,
  "issues": [
    { "type": "punctuation", "offset": 16, "length": 1, "wrong": ",", "correct": null,
      "severity": "warning", "rule_id": "RUN_ON_SENTENCE",
      "message": "建议在复合句中间添加逗号或分号分隔。" },
    { "type": "style", "offset": 12, "length": 4, "wrong": "看了", "correct": "阅读了",
      "severity": "info", "rule_id": "INFORMAL_WORDING",
      "message": "书面语中建议使用更正式的'阅读'替代'看'。" }
  ],
  "issues_count": 2,
  "lang": "zh",
  "quality_score": 78
}

响应示例(无错误)

Response Example (No Errors)

{
  "original": "The quick brown fox jumps over the lazy dog.",
  "corrected": null,
  "issues": [],
  "issues_count": 0,
  "lang": "en",
  "quality_score": 100
}

错误码

Error Codes

HTTP Code错误码Error Code说明Description
2000成功Success
4001001参数错误,请检查必填参数和参数格式Invalid parameter; check required fields and format
4001002不支持的语言代码Unsupported language code
4001003不支持的 check_types 值,请参考检查类型参考表Unsupported check_types value; see check types reference
4001006disable_rules 中包含无效的规则 IDdisable_rules contains invalid rule IDs
4012001认证失败,Token 无效或已过期Authentication failed; invalid or expired token
4032003无权限访问该资源Access denied; insufficient permissions
4133001请求文本超出长度限制(最大 50,000 字符)Text exceeds maximum length (50,000 chars)
4223002无法检测到有效文本内容(文本为空或仅含特殊字符)No valid text content detected (empty or special chars only)
4294001请求频率超限,请稍后重试Rate limit exceeded; please retry later
5005001服务器内部错误,请重试或联系技术支持Internal server error; retry or contact support

最佳实践

Best Practices

  1. 明确指定语言:设置 lang 参数可提高检测准确率,自动检测在短文本场景下可能误判语种。
  2. Specify language explicitly: Setting lang improves accuracy; auto-detect may misidentify short texts.
  3. 按需选择检查类型:若仅需拼写检查,设置 check_types=["spelling"] 可减少无关建议并降低 token 消耗。
  4. Filter check types as needed: Set check_types=["spelling"] for spelling-only check to reduce noise and token usage.
  5. 交互式编辑器用建议模式:保持 auto_correct=false,让用户逐个确认修改,避免误改。
  6. Use suggestion mode for interactive editors: Keep auto_correct=false to let users review each change.
  7. 匹配领域设置:学术论文用 domain=academic,商业邮件用 domain=business,以获得更贴合语境的结果。
  8. Match domain setting: Use domain=academic for papers, domain=business for emails to get context-aware results.
  9. 按位置高亮错误:利用 offsetlength 在前端实现文本选中高亮,提升用户体验。
  10. Highlight errors by position: Use offset and length for text highlighting in the frontend for better UX.
  11. 禁用特定规则:通过 disable_rules 关闭特定检查规则(如连续逗号偏好等),适应团队风格指南。
  12. Disable specific rules: Use disable_rules to turn off certain checks (e.g. serial comma) to match team style guides.

使用场景

Use Cases

场景Scenario推荐参数Recommended Params说明Notes
在线写作助手Online Writing Assistantauto_correct=false, check_types=all实时检查用户输入,下划线标注错误并提供替换建议Real-time check user input, underline errors and suggest replacements
英语学习工具English Learning Toolauto_correct=false, lang=en, severity=error展示语法错误及详细解释,帮助学习者理解错误原因Show grammar errors with detailed explanations to help learners
邮件自动校对Email Auto-Proofreadauto_correct=true, domain=business, severity=warning发送前自动纠正拼写和语法,确保商务邮件的专业性Auto-correct before sending to ensure professional business emails
学术论文审校Academic Paper Reviewauto_correct=false, domain=academic, check_types=["spelling","grammar","style"]全面检查论文中的拼写、语法和学术风格问题Comprehensive check for spelling, grammar, and academic style issues
内容批处理Batch Content Processingauto_correct=true, lang=auto批量处理 CMS 文章或多语言内容,自动修正后发布Batch process CMS articles or multilingual content, auto-correct before publishing
无障碍辅助Accessibility Assistanceseverity=info, check_types=["style","wordiness"]检查文本简洁性和可读性,帮助内容适配阅读障碍群体Check conciseness and readability to make content accessible for dyslexic readers
使用说明
  • 所有 API 请求均使用 HTTPS,建议开启 HTTP Keep-Alive 以提高性能。
  • All API requests use HTTPS; enable HTTP Keep-Alive for better performance.
  • 请勿在客户端代码中暴露 Access Token,建议通过后端代理调用。
  • Do not expose your Access Token in client-side code; use a backend proxy.
  • 推荐设置合理的超时时间(30 秒),并实现指数退避重试策略。
  • Set a reasonable timeout (30s) and implement exponential backoff for retries.
  • 自动检测语言在文本少于 10 个字符时准确率可能下降,建议对此类短文本显式指定 lang
  • Auto language detection accuracy may decrease for texts under 10 characters; specify lang explicitly for short texts.