File size: 1,589 Bytes
d120873 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
## 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
|