更新时间:2024-05-16 GMT+08:00
分享

拼写检查接口

场景描述

给第三方接入方调用,实现拼写检查能力。

当用户输入要查询的问题时,如果输入的句子中存在错别字(中文是同音错字,英文是拼写错误),系统能够具有对这些错误进行纠错的能力。

对接Customer Service Platform系统时,采取Headers头部的userName+token组合鉴权方式,其中userName为ipcc,token获取方式参见C3 智能助手平台接口鉴权方式

对接其他第三方系统,采取请求体的authToken鉴权方式。

接口方法

设置成“POST”。

URL

https://IP:PORT/oifde/rest/api/spellcheck

请求说明

表1 请求体参数

参数名称

数据类型

参数位置

必选/可选

描述

tenantId

String

body

True

租户ID,默认为ipcc用户,即同获取token时,约定好的ipcc用户。

authToken

String

body

True

Token

token失效后,需重新调用获取token接口。

请参见C3 智能助手平台接口鉴权方式

sentence

String

body

True

输入文本,长度限制1024位

language

String

body

True

传入语言参数:

  • zh_CN:中文
  • en_US:英文
  • pt_BR:葡萄牙语

传入语言参数类型要求与输入文本类型匹配。

限制】中英葡语可正常纠错,其他语种文本不做纠错直接返回。再返回的对象中的“是否存在错别字”字段设置为false,即不存在纠错的情况

checkerType

String

body

True

校验类型:

错字纠错: nonWordSpellChecker

别字纠错: realWordSpellChecker

中文仅存在别字纠错。

英文推荐使用错字纠错。

葡语推荐使用错字纠错。

响应说明

参数名称

数据类型

参数位置

必选/可选

描述

hasMistake

boolean

body

True

是否存在错别字:

  • true 表示输入句子中存在错别字
  • false表示输入句子中不存在错别字

spellCheckerMatchList

SpellCheckerMatch[]

body

True

纠错结果

表2 SpellCheckerMatch

参数名称

数据类型

参数位置

必选/可选

描述

word

String

spellCheckerMatchList

True

原始输入中的字

startIndex

int

spellCheckerMatchList

True

word在句子中开始索引

endIndex

int

spellCheckerMatchList

True

word在句子中结束索引

hasMistake

boolean

spellCheckerMatchList

True

该word是否为错别字

correctWord

String

spellCheckerMatchList

True

若word为错别字,则为纠正后的字

报文样例

  • 请求消息样例
    {
        "tenantId": "ipcc",
        "authToken": "0**************************",
        "sentence": "请座",
        "language": "zh_CN",
        "checkerType": "nonWordSpellChecker"
    }
  • 响应消息样例
    {
        "hasMistake": false,
        "spellCheckerMatchList": [
            {
                "word": "请",
                "startIndex": 0,
                "endIndex": 1,
                "hasMistake": false,
                "correctWord": "请"
            },
            {
                "word": "座",
                "startIndex": 1,
                "endIndex": 2,
                "hasMistake": true,
                "correctWord": "坐"
            }
        ]
    }
分享:

    相关文档

    相关产品