hjskhan commited on
Commit
92b2dbc
·
verified ·
1 Parent(s): 13ac375

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +105 -0
app.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import pandas as pd
4
+
5
+ #Assembling and Processing Data
6
+ def prepData(engSL, engHL,
7
+ hindiBSL, hindiBHL,
8
+ spanAbSL, spanAbHL, spanBSL, spanBHL,
9
+ frenchAbSL, frenchAbHL, frenchBSL, frenchBHL,
10
+ bmSL, bmHL, econSL, econHL,
11
+ psychSL, psychHL,
12
+ chemSL, chemHL, bioSL, bioHL,
13
+ phySL, phyHL, csSL, csHL,
14
+ maaSL, maaHL, maiSL, maiHL,
15
+ vaSL, vaHL,
16
+ essSL, essHL):
17
+ data = [engSL, engHL,
18
+ hindiBSL, hindiBHL,
19
+ spanAbSL, spanAbHL, spanBSL, spanBHL,
20
+ frenchAbSL, frenchAbHL, frenchBSL, frenchBHL,
21
+ bmSL, bmHL, econSL, econHL,
22
+ psychSL, psychHL,
23
+ chemSL, chemHL, bioSL, bioHL,
24
+ phySL, phyHL, csSL, csHL,
25
+ maaSL, maaHL, maiSL, maiHL,
26
+ vaSL, vaHL,
27
+ essSL, essHL]
28
+
29
+ # Location for assembling all subjects data
30
+ subsData = []
31
+ subs = "engSL engHL hindiBSL hindiBHL spanAbSL spanAbHL spanBSL spanBHL frenchAbSL frenchAbHL frenchBSL frenchBHL bmSL bmHL econSL econHL psychSL psychHL chemSL chemHL bioSL bioHL phySL phyHL csSL csHL maaSL maaHL maiSL maiHL vaSL vaHL essSL essHL"
32
+ subs = subs.split()
33
+ for i in range(len(subs)):
34
+ subsData.append([subs[i]])
35
+
36
+ # Counters
37
+ k = -1
38
+ count = 0
39
+
40
+ for i in range(len(data)):
41
+ # Inside each subject
42
+ k = k + 1
43
+ lst = data[i].split()
44
+ for j in lst:
45
+ subsData[k].append(j)
46
+
47
+ if len(lst) == 0:
48
+ subsData.remove(subsData[k])
49
+ k = k - 1
50
+
51
+ # Processing Data
52
+ compensations = []
53
+ for sub1 in range(k):
54
+
55
+ for sub2 in range(sub1 + 1, k + 1):
56
+
57
+ compensations.append([subsData[sub1][0] + "/" + subsData[sub2][0]])
58
+ cmn_lst = []
59
+
60
+ for i in range(1, len(subsData[sub1])):
61
+
62
+ for j in range(1, len(subsData[sub2])):
63
+
64
+ if subsData[sub1][i] == subsData[sub2][j]:
65
+ cmn_lst.append(subsData[sub2][j])
66
+
67
+ compensations[count].append(len(cmn_lst))
68
+ cmn_lst = ' '.join(cmn_lst)
69
+ compensations[count].append(cmn_lst)
70
+ count = count + 1
71
+
72
+ for i in range(len(compensations)):
73
+ for j in range(len(compensations[0])):
74
+ if compensations[i][j] == 0:
75
+ compensations[i][j + 1] = "NONE"
76
+
77
+ return pd.DataFrame(compensations, columns=["Parallel Subjects", "No. of Compensations", "Compensations"])
78
+
79
+ def sortData(btnVal, compensation):
80
+
81
+ compensations = compensation.values.tolist()
82
+
83
+ if btnVal == "All":
84
+ return compensation
85
+ if btnVal == "Max 3":
86
+ return [row for row in compensations if row[1] <= 3]
87
+ if btnVal == "Max 2":
88
+ return [row for row in compensations if row[1] <= 2]
89
+ if btnVal == "Max 1":
90
+ return [row for row in compensations if row[1] <= 1]
91
+ if btnVal == "No Compensations":
92
+ return [row for row in compensations if row[1] == 0]
93
+
94
+ interface = gr.Interface(fn=prepData, inputs=[
95
+ *[gr.Textbox(placeholder="Enter student list here", label=f"Student List for {subject}") for subject in
96
+ ["ENGLISH SL", "ENGLISH HL", "HINDI B SL", "HINDI B HL", "SPANISH AB INITIO SL", "SPANISH AB INITIO HL",
97
+ "SPANISH B SL", "SPANISH B HL", "FRENCH AB INITIO SL", "FRENCH AB INITIO HL", "FRENCH B SL", "FRENCH B HL",
98
+ "BM SL", "BM HL", "ECON SL", "ECON HL", "PSYCH SL", "PSYCH HL", "CHEM SL", "CHEM HL", "BIO SL", "BIO HL",
99
+ "PHY SL", "PHY HL", "CS SL", "CS HL", "MAA SL", "MAA HL", "MAI SL", "MAI HL", "VA SL", "VA HL", "ESS SL",
100
+ "ESS HL"]],
101
+ *[gr.Textbox(placeholder="Enter student list here", label=f"Student List for {subject}") for subject in
102
+ ["VA SL", "VA HL", "ESS SL", "ESS HL"]]],
103
+ outputs=gr.Dataframe(headers=["Parallel Subjects", "No. of Compensations", "Compensations"]))
104
+
105
+ interface.launch()