Python client for the Kotoshu HTTP spell-check API.
pip install kotoshufrom kotoshu import Client
client = Client("http://localhost:9292")
# Check a document
result = client.check("helo wrold", language="en")
for err in result.errors:
print(f"{err.word} -> {err.top_suggestions}")
# Suggestions for one word
for sug in client.suggest("helo", max_suggestions=3):
print(sug.word, sug.confidence)
# Language detection
det = client.detect("bonjour le monde")
print(det.language, det.confidence)health() -> dictlanguages() -> list[str]check(text, *, language=None, fmt="full") -> DocumentResultsuggest(word, *, language=None, max_suggestions=None) -> list[Suggestion]detect(text) -> Detectioncorrect(word, *, language=None) -> bool
DocumentResult:file,word_count,errors: list[WordError],success,misspelled_wordsWordError:word,position,suggestions: list[Suggestion],top_suggestionsSuggestion:word,distance,confidence,source,metadataDetection:language,confidence
KotoshuError: baseResourceNotSetupError: server returned 422 — language not set up
BSD-2-Clause, same as Kotoshu.