Isabel Gwara commited on
Commit
6c7177e
1 Parent(s): 2279957

Upload reader.py

Browse files
Files changed (1) hide show
  1. reader.py +163 -0
reader.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from yattag import Doc
3
+ ## --------------------------------- ###
4
+ ### reading: info.txt ###
5
+ ### -------------------------------- ###
6
+ # placeholders in case info.txt does not exist
7
+ def get_article(acc, most_imp_feat):
8
+ filename = "info.txt"
9
+ placeholder = "please create an info.txt to customize this text"
10
+ note = "**Note that model accuracy and most important feature reflect assumptions made by the model about the world, and may be inaccurate. These can be helpful for understanding how the model works, but should not be considered absolute facts."
11
+
12
+ title = bkgd = data_collection = priv_cons = bias_cons = ident_cons = img_src = membs = placeholder
13
+ # check if info.txt is present
14
+ if os.path.isfile(filename):
15
+ # open info.txt in read mode
16
+ info = open(filename, "r")
17
+
18
+ # read each line to a string
19
+ description = "An AI project created by " + info.readline()
20
+ title = info.readline()
21
+ bkgd = info.readline()
22
+ data_collection = info.readline()
23
+ priv_cons = info.readline()
24
+ bias_cons = info.readline()
25
+ ident_cons = info.readline()
26
+ img_src = info.readline()
27
+ membs = info.readline()
28
+
29
+ # close file
30
+ info.close()
31
+
32
+ # use yattag library to generate html
33
+ doc, tag, text, line = Doc().ttl()
34
+ # create html based on info.txt
35
+ with tag('div'):
36
+ with tag('div', klass='box model-container'):
37
+ with tag('div', klass='spacer'):
38
+ with tag('div', klass='box model-div'):
39
+ line('h2', "Model Accuracy", klass='acc')
40
+ line('p', acc)
41
+ with tag('div', klass='box model-div'):
42
+ line('h2', "Most Important Feature", klass='feat')
43
+ line('p', most_imp_feat)
44
+ with tag('div', klass='spacer'):
45
+ line('p', note)
46
+ with tag('div', klass='box'):
47
+ line('h2', 'Problem Statement and Research Summary', klass='prj')
48
+ line('p', bkgd)
49
+ with tag('div', klass='box'):
50
+ line('h2', 'Data Collection Plan', klass='data')
51
+ line('p', data_collection)
52
+ with tag('div', klass='box'):
53
+ line('h2', 'Ethical Considerations', klass='ethics')
54
+ with tag('ul'):
55
+ line('li', priv_cons)
56
+ line('li', bias_cons)
57
+ line('li', ident_cons)
58
+ with tag('div', klass='box'):
59
+ line('h2', 'Our Team', klass='team')
60
+ line('p', membs)
61
+ doc.stag('img', src=img_src)
62
+
63
+ css = '''
64
+ .box {
65
+ border: 2px solid black;
66
+ text-align: center;
67
+ margin: 10px;
68
+ padding: 5%;
69
+ }
70
+ ul {
71
+ display: inline-block;
72
+ text-align: left;
73
+ }
74
+ img {
75
+ display: block;
76
+ margin: auto;
77
+ }
78
+ .description {
79
+ text-align: center;
80
+ }
81
+ .panel_button {
82
+ display: block !important;
83
+ width: 100% !important;
84
+ background-color: #00EACD !important;
85
+ color: #000;
86
+ transition: all .2s ease-out 0s !important;
87
+ box-shadow: 0 10px #00AEAB !important;
88
+ border-radius: 10px;
89
+ }
90
+ .panel_button:hover {
91
+ box-shadow: 0 5px #00AEAB;
92
+ transform: translateY(5px);
93
+ }
94
+ .submit {
95
+ color: black !important;
96
+ }
97
+ .selected {
98
+ background-color: #656bd6 !important;
99
+ }
100
+ .panel_header:hover {
101
+ color: #656bd6 !important;
102
+ }
103
+ .input_radio:hover {
104
+ color: #656bd6 !important;
105
+ }
106
+ .radio_item {
107
+ border-radius: 10px;
108
+ padding-left: 10px !important;
109
+ padding-right: 10px !important;
110
+ }
111
+ .title {
112
+ background-image: url(https://media.giphy.com/media/26BROrSHlmyzzHf3i/giphy.gif);
113
+ background-size: cover;
114
+ color: transparent;
115
+ -moz-background-clip: text;
116
+ -webkit-background-clip: text;
117
+ text-transform: uppercase;
118
+ font-size: 120px;
119
+ line-height: .75;
120
+ margin: 10px 0;
121
+ }
122
+ input {
123
+ background-color: #efeffa !important;
124
+ }
125
+ .acc, .feat {
126
+ background-color: #FF3399 !important
127
+ }
128
+ .prj {
129
+ background-color: #FFCE3B !important;
130
+ }
131
+ .data {
132
+ background-color: #ED6800 !important;
133
+ }
134
+ .ethics {
135
+ background-color: #3EE6F9 !important;
136
+ }
137
+ .team {
138
+ background-color: #9581EF !important;
139
+ }
140
+ .model-container {
141
+ display: flex;
142
+ flex-direction: column;
143
+ justify-content: center;
144
+ }
145
+ .spacer {
146
+ display: flex;
147
+ justify-content: center;
148
+ }
149
+ .model-div {
150
+ width: 45%;
151
+ }
152
+ @media screen and (max-width: 700px) {
153
+ .model-container {
154
+ flex-wrap: wrap;
155
+ }
156
+ }
157
+ '''
158
+ return {
159
+ 'article': doc.getvalue(),
160
+ 'css': css,
161
+ 'title': title,
162
+ 'description': description,
163
+ }