Download language/correction_service.py from Sahaltech/AI-API: direct link, hf CLI and curl.
- Browser
- Download file 481 Bytes
-
https://huggingface.co/spaces/Sahaltech/AI-API/resolve/main/language/correction_service.py
- Command line
-
hf download hf://spaces/Sahaltech/AI-API/language/correction_service.py
-
curl -L -o correction_service.py https://huggingface.co/spaces/Sahaltech/AI-API/resolve/main/language/correction_service.py
481 Bytes
| import language_tool_python | |
| class CorrectionService: | |
| def __init__(self): | |
| self.tools = { | |
| "fra_Latn": language_tool_python.LanguageTool("fr"), | |
| "eng_Latn": language_tool_python.LanguageTool("en"), | |
| } | |
| def correctText(self, text: str, sourceLang: str) -> str: | |
| tool = self.tools.get(sourceLang) | |
| if tool is None: | |
| raise ValueError(f"Langue non supportée : {sourceLang}") | |
| return tool.correct(text) | |