-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleaner.py
107 lines (102 loc) · 3.94 KB
/
cleaner.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import makeCalendar
#Quiz number day month time
list=['quiz','quizzes','test','tests','assignment','assignments','lab','labs','exam','exams','presentation','presentations','report','reports', 'case', 'cases','due', 'submission', 'submissions', 'forms', 'form', 'plan', 'plans']
months1=['Jan.','Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.']
months=['Jan','Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
months2=['January','February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
days=[]
invalid='\u25aa'
dayWeek=['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
for x in range (31):
days.append(x+1)
def cleaning (longString):
allLines = []
allGoodLines = []
matrix = []
matrix.append([])
matrix.append([])
#current=os.getcwd(courseName)
f=open("wrapper.txt", "w")
f.write(longString)
f.close()
path = r'C:\Users\jason\PycharmProjects\QHacks2019 2.0\wrapper.txt'
file=open(path, encoding="utf-8")
for line in file:
goodLine=[]
buzzWordName = ""
dayOf = "0"
monthOf = ""
numOf = ""
allWords=line.split()
acc = 1
print(line)
for i in range (len(allWords)):
word=allWords[i]
for ii in range (len(list)):
if word.lower()[len(word)-1] == ':':
word=word.lower()[0:len(word)-1]
if word.lower() == list[ii].lower():
acc=acc*2
if buzzWordName == "":
buzzWordName=word.lower()
string = ""
try:
for iii in range (len(allWords[i+1][0])):
char = allWords[i+1][iii]
if char.isdigit():
string += char
numOf = string
except:
a=''
for y in range (12):
if word != months[y] and word != months1[y] and word != months2[y]:
continue
else:
acc=acc*-1
monthOf=word
for z in range (30):
z+=1
if z<10 and (allWords[i+1][0:1] == str(days[z])) and allWords[i+1][1:2] not in ["0","1","2","3","4","5","6","7","8","9"]:
acc=acc*2
dayOf=(allWords[i+1][0:1])
elif allWords[i+1][0:2] == str(days[z]):
acc=acc*2
dayOf=(allWords[i+1][0:2])
for zz in range (7):
if dayWeek[zz] == word.lower():
acc=acc*2
#dayWeekOf=word.lower()
if acc <= -2:
buzzWordName=buzzWordName.upper()
if numOf == "":
goodLine.extend([buzzWordName, monthOf, dayOf])
else:
goodLine.extend([buzzWordName + " " + numOf, monthOf, dayOf])
if invalid in line:
line=line.replace(invalid, "-")
matrix[0].append(line)
matrix[1].append(goodLine)
return matrix
def splittingMatrix (matrix):
matrixGood=[]
matrixGood.append([])
matrixGood.append([])
matrixMore=0
for x in range(len(matrix[1])):
if matrix[1][x][0] is not '':
matrixGood[0].append(matrix[0][x])
matrixGood[1].append(matrix[1][x])
else:
matrixMore=1
return matrixGood, matrixMore
def main(longString):
print(longString)
#call the cleaning function
#return good and bad values
m=cleaning(longString)
print(m)
matrixG, indicator=splittingMatrix(m)
if matrixG[0]:
makeCalendar.main(matrixG)
'''
'''