import os from yattag import Doc ## --------------------------------- ### ### reading: info.txt ### ### -------------------------------- ### # placeholders in case info.txt does not exist def get_article(acc, most_imp_feat): filename = "info.txt" placeholder = "please create an info.txt to customize this text" 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." title = bkgd = data_collection = priv_cons = bias_cons = img_src = membs = description = placeholder # check if info.txt is present if os.path.isfile(filename): # open info.txt in read mode info = open(filename, "r") # read each line to a string description = "An AI project created by " + info.readline() title = info.readline() bkgd = info.readline() data_collection = info.readline() priv_cons = info.readline() bias_cons = info.readline() img_src = info.readline() membs = info.readline() # close file info.close() # use yattag library to generate html doc, tag, text, line = Doc().ttl() # create html based on info.txt with tag('div'): with tag('div', klass='box model-container'): with tag('div', klass='spacer'): with tag('div', klass='box model-div'): line('h2', "Model Accuracy", klass='acc') line('p', acc) with tag('div', klass='box model-div'): line('h2', "Most Important Feature", klass='feat') line('p', most_imp_feat) with tag('div', klass='spacer'): line('p', note) with tag('div', klass='box'): line('h2', 'Problem Statement and Research Summary', klass='prj') line('p', bkgd) with tag('div', klass='box'): line('h2', 'Data Collection Plan', klass='data') line('p', data_collection) with tag('div', klass='box'): line('h2', 'Ethical Considerations (Data Privacy and Bias)', klass='ethics') with tag('ul'): line('li', priv_cons) line('li', bias_cons) with tag('div', klass='box'): line('h2', 'Our Team', klass='team') line('p', membs) doc.stag('img', src=img_src) css = 'app.css' return { 'article': doc.getvalue(), 'css': css, 'title': title, 'description': description, }