-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreprocessor.py
48 lines (37 loc) · 1.34 KB
/
preprocessor.py
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
# -*- coding: utf-8 -*-
"""
******************************************************************************************************************
@author: Ananya Mukherjee
Name: ner.py
Description : This program preprocess the input and checks validation.
Input : Input Type and Input Text.
Checks if entered input is empty or not.
Checks if entered input is in English or not.
Output : Returns 'Error Message' if an error is encountered else returns 'True'.
******************************************************************************************************************
"""
class PreProcess:
def __init__(self,inpTyp,input):
self.inpTyp = inpTyp
self.input = str(input)
def isNotEnglish(self):
input = self.input
try:
input.encode('ascii')
except UnicodeEncodeError:
input.encode('utf-8')
return True
else:
return False
def isEmpty(self):
if(not (self.input and self.input.strip())):
return True
else:
return None
def validateInput(self):
if(self.isEmpty()):
return "Please provide input."
elif(self.isNotEnglish()):
return "Please provide input in English."
else:
return True