isabel/pet-project
2
1import os2from yattag import Doc3## --------------------------------- ###4### reading: info.txt ###5### -------------------------------- ###6# placeholders in case info.txt does not exist7def 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 is based on the uploaded data.csv and reflects how well the AI model can give correct recommendations for that dataset. An accuracy of 50% means that half of the model's predictions for that dataset were accurate. Model accuracy and most important feature can be helpful for understanding how the model works, but should not be considered absolute facts about the real world."11 12 title = bkgd = data_collection = priv_cons = bias_cons = img_src = membs = description = placeholder13 # check if info.txt is present14 if os.path.isfile(filename):15 # open info.txt in read mode16 info = open(filename, "r")17 18 # read each line to a string19 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 img_src = info.readline()26 membs = info.readline()27 28 # close file29 info.close()30 31 # use yattag library to generate html32 doc, tag, text, line = Doc().ttl()33 # create html based on info.txt34 with tag('div'):35 with tag('div', klass='box model-container'):36 with tag('div', klass='spacer'):37 with tag('div', klass='box model-div'):38 line('h2', "Model Accuracy", klass='acc')39 line('p', acc)40 with tag('div', klass='box model-div'):41 line('h2', "Most Important Feature", klass='feat')42 line('p', most_imp_feat)43 with tag('div', klass='spacer'):44 line('p', note)45 with tag('div', klass='box'):46 line('h2', 'Problem Statement and Research Summary', klass='prj')47 line('p', bkgd)48 with tag('div', klass='box'):49 line('h2', 'Data Collection Plan', klass='data')50 line('p', data_collection)51 with tag('div', klass='box'):52 line('h2', 'Ethical Considerations (Data Privacy and Bias)', klass='ethics')53 with tag('ul'):54 line('li', priv_cons)55 line('li', bias_cons)56 with tag('div', klass='box'):57 line('h2', 'Our Team', klass='team')58 line('p', membs)59 doc.stag('img', src=img_src)60 61 css = '''62 .box {63 border: 2px solid black;64 text-align: center;65 margin: 10px;66 padding: 5%;67 }68 ul {69 display: inline-block;70 text-align: left;71 }72 img {73 display: block;74 margin: auto;75 }76 .description {77 text-align: center;78 }79 .panel_button {80 display: block !important;81 width: 100% !important;82 background-color: #00EACD !important;83 color: #000;84 transition: all .2s ease-out 0s !important; 85 box-shadow: 0 10px #00AEAB !important;86 border-radius: 10px !important;87 }88 .panel_button:hover {89 box-shadow: 0 5px #00AEAB;90 transform: translateY(5px);91 }92 .submit {93 color: black !important;94 }95 .selected {96 background-color: #656bd6 !important;97 }98 .radio_item {99 border-radius: 10px;100 padding-left: 10px !important;101 padding-right: 10px !important;102 }103 .radio_item:hover {104 color: #656bd6 !important;105 }106 .title {107 background-image: url(https://media.giphy.com/media/26BROrSHlmyzzHf3i/giphy.gif);108 background-size: cover;109 color: transparent;110 -moz-background-clip: text;111 -webkit-background-clip: text;112 text-transform: uppercase;113 font-size: 60px;114 line-height: .75;115 margin: 10px 0;116 }117 .panel_header {118 color: black !important;119 }120 input {121 background-color: #efeffa !important;122 }123 .acc, .feat {124 background-color: #FF3399 !important125 }126 .prj {127 background-color: #FFCE3B !important;128 }129 .data {130 background-color: #ED6800 !important;131 }132 .ethics {133 background-color: #3EE6F9 !important;134 }135 .team {136 background-color: #9581EF !important; 137 }138 .model-container {139 display: flex;140 flex-direction: column;141 justify-content: center;142 }143 .spacer {144 display: flex;145 justify-content: center;146 }147 .model-div {148 width: 45%;149 }150 @media screen and (max-width: 700px) {151 .model-container {152 flex-wrap: wrap;153 }154 }155 '''156 return {157 'article': doc.getvalue(),158 'css': css,159 'title': title,160 'description': description,161 }