Updated on 2023-09-27 GMT+08:00

Spelling Check Interface

Description

This interface is invoked by a third-party system to check the spelling.

When a subscriber enters the question to be queried, the system can correct the errors if the entered sentence contains wrong spellings (homonyms in Chinese and spellings in English).

When the system connects to the CSP, userName and token in the header are used for authentication. The value of userName is ipcc. For details about how to obtain the token, see C3 OIAP Interface Authentication.

When other third-party systems are connected, authToken in the request body is used for authentication.

Interface Method

The request method must be set to POST.

URL

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

Request

Table 1 Parameters in the request body

Parameter

Type

Position

Mandatory

Description

tenantId

String

body

Yes

Tenant ID. The default value is ipcc, that is, the ipcc subscriber agreed upon token obtaining.

authToken

String

body

Yes

Token.

After the token expires, the token obtaining interface needs to be invoked again.

For details, see C3 OIAP Interface Authentication.

sentence

String

body

Yes

Input text. The value contains a maximum of 4096 characters.

language

String

body

Yes

Language.

  • zh_CN: Chinese
  • en_US: English

The type of the language must match that of the input text.

[Restrictions] The errors in the Chinese and English texts can be corrected. Texts in other languages are directly returned without error correction. In the returned object, the hasMistake field is set to false, indicating that no error correction exists.

checkerType

String

body

Yes

Verification type.

nonWordSpellChecker: spelling error correction

realWordSpellChecker: wrongly written character correction

Wrongly written character correction is recommended for Chinese.

Spelling error correction is recommended for English.

Response

Parameter

Type

Position

Mandatory

Description

hasMistake

boolean

body

Yes

Whether there is any spelling error.

  • true: The sentence contains misspellings.
  • false: The sentence does not contain misspellings.

spellCheckerMatchList

SpellCheckerMatch[]

body

Yes

Error correction result.

Table 2 SpellCheckerMatch

Parameter

Type

Position

Mandatory

Description

word

String

spellCheckerMatchList

Yes

Word in the original input.

startIndex

Integer

spellCheckerMatchList

Yes

Start index of the word in a sentence.

endIndex

Integer

spellCheckerMatchList

Yes

End index of the word in a sentence.

hasMistake

boolean

spellCheckerMatchList

Yes

Whether the word is misspelled.

correctWord

String

spellCheckerMatchList

Yes

Corrected word if a word is misspelled.

Example

  • Request
    {
        "tenantId": "ipcc",
        "authToken": "0**************************",
        "sentence": "eat apply",
        "language": "zh_CN",
        "checkerType": "nonWordSpellChecker"
    }
  • Response
    {
        "hasMistake": false,
        "spellCheckerMatchList": [
            {
                "word": "Eat",
                "startIndex": 0,
                "endIndex": 1,
                "hasMistake": false,
                "correctWord": "eat"
            },
            {
               "word": "apply",
                "startIndex": 1,
                "endIndex": 2,
                "hasMistake": true,
                "correctWord": "apple"
            }
        ]
    }