/
lexalexuss
/
Fast-API-Note-Service
Обзор
Документация
Войти
/
lexalexuss
/
Fast-API-Note-Service
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
app/speller.py
15 строк
638 B
Alexey
first_commit
18 сен 2024, 14:49
18 сен 2024, 14:49
b1e3ffd
Код
Авторство
О чём код?
import httpx SPELLER_URL = "https://speller.yandex.net/services/spellservice.json/checkText" # Асинхронная функция для проверки орфографии через Яндекс.Спеллер async def check_spelling(text: str) -> str: async with httpx.AsyncClient() as client: response = await client.get(SPELLER_URL, params={"text": text}) corrections = response.json() for correction in corrections: word = correction["word"] suggestions = correction["s"][0] if correction["s"] else word text = text.replace(word, suggestions) return text