Skip to content

Spellcheck API

The Spellcheck API validates Nepali text and provides correction suggestions for misspelled words.

Endpoints

Method Endpoint Description
POST /api/v1/spellcheck/text Check spelling of text
GET /api/v1/spellcheck/word Check a single word

Check Text

Validate a block of Nepali text and get suggestions for misspelled words.

Request

POST /api/v1/spellcheck/text
Content-Type: application/json
Field Type Required Description
text string Yes The Nepali text to check

Example Request

curl -X POST "https://sabdasakha.com/api/v1/spellcheck/text" \
  -H "Content-Type: application/json" \
  -d '{"text": "नेपाल सुन्दर देस हो"}'
import requests

response = requests.post(
    "https://sabdasakha.com/api/v1/spellcheck/text",
    json={"text": "नेपाल सुन्दर देस हो"}
)
result = response.json()

for error in result["misspelled"]:
    print(f"{error['word']} -> {error['corrections']}")
const response = await fetch(
  "https://sabdasakha.com/api/v1/spellcheck/text",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      text: "नेपाल सुन्दर देस हो"
    })
  }
);
const result = await response.json();

result.misspelled.forEach(error => {
  console.log(`${error.word} -> ${error.corrections.join(", ")}`);
});

Success Response (200)

{
  "misspelled": [
    {
      "word": "देस",
      "status": "misspelled",
      "corrections": ["देश"]
    }
  ],
  "unknown": []
}
Field Type Description
misspelled array List of misspelled words with corrections
misspelled[].word string The misspelled word
misspelled[].status string Always "misspelled"
misspelled[].corrections array Correction suggestions
unknown array Words not found in dictionary (no corrections available)

No Errors Response

When all words are spelled correctly:

{
  "misspelled": [],
  "unknown": []
}

Check Single Word

Check the spelling of a single word.

Request

GET /api/v1/spellcheck/word?word={word}
Parameter Type Required Description
word string Yes The word to check

Example Request

curl "https://sabdasakha.com/api/v1/spellcheck/word?word=देस"
response = requests.get(
    "https://sabdasakha.com/api/v1/spellcheck/word",
    params={"word": "देस"}
)
result = response.json()
const response = await fetch(
  "https://sabdasakha.com/api/v1/spellcheck/word?word=देस"
);
const result = await response.json();

Response - Misspelled Word

{
  "status": "misspelled",
  "corrections": ["देश"]
}

Response - Correct Word

{
  "status": "correct",
  "corrections": null
}

Response - Unknown Word

{
  "status": "unknown",
  "corrections": null
}
Field Type Description
status string One of: "correct", "misspelled", "unknown"
corrections array|null Correction suggestions (null if correct or unknown)

How It Works

The spellcheck API uses a multi-stage validation process:

  1. Bloom Filter - Fast probabilistic check (0.1% false positive rate)
  2. Root Word Analysis - Checks word stems and common suffixes
  3. Dictionary Lookup - Validates against comprehensive word vocabulary
  4. Fuzzy Matching - Generates suggestions using edit distance

This approach provides sub-100ms response times for typical text.


Text Limits

The API enforces the following limits and returns 400 Bad Request when exceeded:

Limit Value
Maximum text length 10,000 characters
Maximum words per request 1,000 words

For larger documents, split the text into chunks.

Limit Exceeded Response (400)

{
  "detail": "Text exceeds 10000 characters"
}

Common Misspellings

The API is trained to catch common Nepali spelling errors:

Error Type Example Correct
ष/स confusion देस देश
ृ/्र confusion प्रक्रति प्रकृति
Half-letter errors गर्नु गर्नु
Chandrabindu हुछ हुँछ

Best Practices

  1. Batch requests - Check full paragraphs instead of word-by-word
  2. Cache common words - Reduce API calls for frequently typed words
  3. Limit suggestions shown - Display 2-3 suggestions, not all
  4. Handle unknown words - These may be proper nouns or technical terms