-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcheck.py
More file actions
62 lines (57 loc) · 1.96 KB
/
check.py
File metadata and controls
62 lines (57 loc) · 1.96 KB
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
import string,io
def detect_language(character):
maxchar = max(character)
if (u'\u0900' <= maxchar <= u'\u097f') or (maxchar == '\n') or (maxchar == u'\u0020'):
return 'hindi'
def detect_language_punctuation(character):
maxchar = max(character)
if (u'\u0900' <= maxchar <= u'\u097f') or (u'\u0020' <= maxchar <= u'\u002f') or (maxchar == '\n'):
return 'hindi'
def detect_language_processed(character):
maxchar = max(character)
if (u'\u0900' <= maxchar <= u'\u097f'):
return 'hindi'
def fileReader(location):
location2 = "" + location + ""
fo = io.open("output.txt", "w", encoding='utf-8')
with io.open(location2, encoding='utf-8') as f:
input = f.read()
for i in input:
isEng = detect_language(i)
if isEng == "hindi":
#Hindi Character
#add this to another file
fo.write(i)
fo.close()
f.close()
check = processedText()
def punctuation(location):
location2 = "" + location + ""
fo = io.open("output.txt", "w", encoding='utf-8')
with io.open(location2, encoding='utf-8') as f:
input = f.read()
for i in input:
isEng = detect_language_punctuation(i)
if isEng == "hindi":
#Hindi Character
#add this to another file
fo.write(i)
fo.close()
f.close()
check = processedText()
def processedText():
with io.open("output.txt", encoding='utf-8') as f:
para=""
lines=f.readlines()
for line in lines:
check=0
for i in line:
isEng = detect_language_processed(i)
if isEng == "hindi":
check=1
break
if check==1:
line=line.lstrip(" ")
para=para+line
fo = io.open("output.txt", "w", encoding='utf-8')
fo.write(para)