-
Notifications
You must be signed in to change notification settings - Fork 35
/
checker.py
34 lines (29 loc) · 1.09 KB
/
checker.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
import os
from alphabet_detector import AlphabetDetector
def check_double(file):
words = file.readlines()
words1 = list(dict.fromkeys(words))
if len(words) != len(words1):
return "Duplicate words on "+file.name+". Please check again."
return "PASS"
def check_case(file):
lists = file.readlines()
ad = AlphabetDetector()
for word in lists:
if word.isalpha() and ad.is_latin(word) and word.islower() == False:
print(word)
return "Please repair the case to lowercase in "+file.name+"."
return "PASS"
def check_unwanted_occurences(file):
lists = file.readlines()
punc = '!"#$%&()*+,/:;<=>?@[\\]^`{|}~'
for word in lists:
if any(j.isdigit() or j in punc for j in word):
return "Unwanted occurence in "+word+" in "+file.name+"."
if len(word.split()) > 1:
return "Every lines should contain only one word and no any space!\nPlease check the word "+word+" in "+file.name
return "PASS"
# filename = ""
# file = open("./list/" + filename, encoding='utf-8')
# print(check_case(file))
# file.close()