Spellcheck
For some use cases, grammar and phrase-level edits may not be necessary. If your application only requires spellcheck, the Sapling Spellcheck endpoint is a faster, cheaper solution.
The Spellcheck endpoint does not provide grammar and phrase-level suggestions, unlike the Edits endpoint.
The results you get with neural_spellcheck
set to true
should match those from pasting the text on https://sapling.ai/utilities/spelling
If the results do not match, check that you're not adding additional newlines
or adding unnecessary character escaping (e.g. \\r
or \\n
) in your request.
The Spellcheck endpoint supports additional languages that the edits
endpoint
does not.
In addition, Sapling offers custom dictionaries for industries including:
- Medical / healthcare
- Biomedical applications
- Speech transcriptions (outputs of automatic speech recognition [ASR] systems)
- Localization / translations (outputs of machine translation systems)
Please contact us if your language is not supported or if you're interested in the custom dictionaries.
Request Spellcheck POST
Sometimes you may want to only perform spellcheck without grammar edits.
In that case, use the Spellcheck endpoint.
https://api.sapling.ai/api/v1/spellcheck
For those who only wish to spellcheck medical terms, use the /api/v1/medical-spellcheck
endpoint instead.
HTTP method: POST
The Spellcheck endpoint takes the same arguments as the edits endpoint.
However, it does not return an error_type
or general_error_type
field.
Where possible, the Spellcheck endpoint will also only return edits for individual words,
while the Edits endpoint will suggest phrase-level edits.
Sample Code
- cURL
- JavaScript
- Python
- Python SDK
curl -X POST https://api.sapling.ai/api/v1/spellcheck \
-H "Content-Type: application/json" \
-d '{"key":"<api-key>", "text":"There are speling mistakes here.", "session_id": "test session"}'
import axios from 'axios';
async function run(text) {
try {
const response = await axios.post(
'https://api.sapling.ai/api/v1/spellcheck',
{
key: '<api-key>', // replace with your API key
session_id: 'test session',
text,
},
);
const {status, data} = response;
console.log({status});
console.log(JSON.stringify(data, null, 4));
} catch (err) {
const { msg } = err.response.data;
console.log({err: msg});
}
}
run('There are speling mistakes here.'); // replace with the text you want to analyze
import requests
from pprint import pprint
try:
response = requests.post(
"https://api.sapling.ai/api/v1/spellcheck",
json={
"key": "<api-key>",
"text": "There are speling mistakes here.",
"session_id": "test session"
}
)
resp_json = response.json()
if 200 <= response.status_code < 300:
edits = resp_json['edits']
pprint(edits)
else:
print('Error: ', resp_json)
except Exception as e:
print('Error: ', e)
# python -m pip install sapling-py
from sapling import SaplingClient
from pprint import pprint
api_key ='<api-key>'
client = SaplingClient(api_key=api_key)
edits = client.edits('There are speling mistakes here.', session_id='test_session')
pprint(edits)
Request Arguments
key: String
32-character API key
text: String
Text to process for edits.
min_length: Integer
Minimum character length of words to suggest corrections for.
Setting this too low will result in much higher false positives.
The default value is 3
.
session_id: String
Unique name or UUID of document or portion of text that is being checked.
multiple_edits: Optional Boolean
Default is false. If true, will return candidates
field containing list of other potential corrections for each error.
neural_spellcheck: Optional Boolean
Default for API keys created from 2024-06-20 onwards is true
(was previously false).
If true
, endpoint backend will use more contextual neural (GPT-style) model to make spelling suggestions.
We recommend the neural model but it is currently only available for a subset of languages
[da
, de
, en
, es
, fi
, fr
, id
, it
, nl
, no
, pl
, pt
, sv
, tl
, tr
]
and with multiple_edits=false
.
However, it can be used in combination with the non-neural model with multiple_edits=true
.
operations: Optional List of Strings
Default is []
. Possible operations are described in the Postprocess documentation.
This will run postprocessing on outputs before returning results so you can enforce
stricter capitalization, punctuation, and whitespace removal.
lang: Optional String
Supported languages are:
auto
: Autodetect languageen
: Englishar
: عربيbg
: българскиca
: catalàcs
: češtinada
: danskde
: Deutschel
: Ελληνικάes
: españolet
: eesti keelfa
: فارسیfi
: suomifr
: français (fr-fr
andfr-ca
coming soon)he
: עִבְרִיתhi
: हिन्दी",hr
: hrvatski,hu
: magyar nyelvid
: bahasa Indonesiais
: íslenskait
: italianojp/ja
: 日本語ko
: 한국어lt
: lietuvių kalbalv
: latviešu valodanl
: Nederlandsno
: norskpl
: polskipt
: portuguêsro
: limba românăru
: русскийsk
: slovenčinasq
: shqipsr
: srpskisv
: svenskath
: ภาษาไทยtl
: Tagalog / ᜆᜄᜎᜓᜄ᜔tr
: Türkçeuk
: Українська моваvi
: Tiếng Việtzh
: 中文
variety: Optional String
Supported Varieties
This option is currently available for: English, Chinese (中文). Specifies regional English/Chinese spelling options. The setting defaults to the configuration in the Sapling dashboard.
Supported varieties:
English:
us-variety
: American Englishgb-variety
: British Englishau-variety
: Australian Englishca-variety
: Canadian Englishnull-variety
: Don’t suggest any changes based on English variety
Chinese (中文)
s-variety
: Simplified Chineset-variety
: Traditional Chinese