| |
| 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." |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
| |