Spaces:
Running
Running
Download src/exception/Exception.py from TiberiuCristianLeon/FastAPIMT: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/TiberiuCristianLeon/FastAPIMT/resolve/main/src/exception/Exception.py
- Command line
-
hf download hf://spaces/TiberiuCristianLeon/FastAPIMT/src/exception/Exception.py
-
curl -L -o Exception.py https://huggingface.co/spaces/TiberiuCristianLeon/FastAPIMT/resolve/main/src/exception/Exception.py
1.58 kB
| ## Exception | |
| TOO_SHORT = "The length of text you sent to me is too short. Minimum length is 20 characters." | |
| TOO_LONG = "The length of text you sent to me is too long. maximum length is 400 characters." | |
| ## End Exception | |
| def checkForException(requestValue : str, METHOD : str): | |
| exception = "" | |
| if METHOD == "SYNONYM": | |
| exception = checkExceptionSynosnym(requestValue) | |
| elif METHOD == "TRANSLATE": | |
| exception = checkExceptionTranslate(requestValue) | |
| elif METHOD == "PARAPHRASE": | |
| exception = checkExceptionParaphrase(requestValue) | |
| elif METHOD == "PIPELINE": | |
| exception = checkExceptionPipeline(requestValue) | |
| return exception | |
| def checkExceptionSynosnym(requestValue : str): | |
| exception = "" | |
| if len(requestValue) < 20: | |
| exception = TOO_SHORT | |
| return exception | |
| elif len(requestValue) > 400: | |
| exception = TOO_LONG | |
| return exception | |
| else: | |
| return exception | |
| def checkExceptionTranslate(requestValue : str): | |
| exception = "" | |
| if len(requestValue) < 20: | |
| exception = TOO_SHORT | |
| return exception | |
| elif len(requestValue) > 400: | |
| exception = TOO_LONG | |
| return exception | |
| else: | |
| return exception | |
| def checkExceptionParaphrase(requestValue : str): | |
| exception = "" | |
| if len(requestValue) < 20: | |
| exception = TOO_SHORT | |
| return exception | |
| elif len(requestValue) > 400: | |
| exception = TOO_LONG | |
| return exception | |
| else: | |
| return exception | |
| def checkExceptionPipeline(requestValue : str): | |
| exception = "" | |
| if len(requestValue) < 20: | |
| exception = TOO_SHORT | |
| return exception | |
| elif len(requestValue) > 400: | |
| exception = TOO_LONG | |
| return exception | |
| else: | |
| return exception | |