def legislatr_input4(): bill_type = app.var['bill_type'] congress = app.var['congress'] bill_list = app.var['bill_list'] bill_number = request.args.get('bill_number') app.var['bill_number'] = bill_number title = legis_funcs.retrieveTitle(bill_type,bill_number,congress,db) app.var['title'] = title return render_template("input4.html", congress=congress, bill_type=bill_type, bill_list=bill_list, bill_title=title, bill_number=bill_number)
def legislatr_inputSearch2(): ind = int(request.args.get('user_choice')) options = app.var["options"] option = options[ind] query_db = app.var["query_db"] congress = query_db["congress"].iloc[ind] bill_type = query_db["bill_type"].iloc[ind] bill_number = query_db["bill_number"].iloc[ind] title = legis_funcs.retrieveTitle(bill_type,bill_number,congress,db) app.var['title'] = title app.var['bill_type'] = bill_type app.var['bill_number'] = bill_number app.var['congress'] = congress return render_template("inputSearch2.html", bill_choice=ind, congress=congress, bill_type=bill_type,bill_number=bill_number,bill_title=title,bill_options=options)
def legislatr_input4(): bill_type = app.var['bill_type'] congress = app.var['congress'] bill_list = app.var['bill_list'] bill_number = request.args.get('bill_number') app.var['bill_number'] = bill_number title = legis_funcs.retrieveTitle(bill_type, bill_number, congress, db) app.var['title'] = title return render_template("input4.html", congress=congress, bill_type=bill_type, bill_list=bill_list, bill_title=title, bill_number=bill_number)
def legislatr_input4(): #read data json_name = request.args.get('data_file') with open('legislatr/static/'+json_name+'.p','rb') as fp: data = pickle.load(fp) bill_type = data['bill_type'] congress = data['congress'] bill_list = data['bill_list'] bill_number = request.args.get('bill_number') data['bill_number'] = bill_number title = legis_funcs.retrieveTitle(bill_type,bill_number,congress,db) data['title'] = title with open('legislatr/static/'+json_name+'.p','wb') as fp: pickle.dump(data,fp) return render_template("input4.html", congress=congress, bill_type=bill_type, bill_list=bill_list, bill_title=title, bill_number=bill_number,data_file=json_name)
def legislatr_sample(): json_name = request.args.get('data_file') data = {} bill_type = request.args.get('bill_type') congress = request.args.get('congress') bill_number = request.args.get('bill_number') title = legis_funcs.retrieveTitle(bill_type,bill_number,congress,db) data['title'] = title data['bill_type'] = bill_type data['bill_number'] = bill_number data['congress'] = congress model = legis_funcs.initModel('forest') bill = legis_funcs.getBill(bill_type,bill_number,congress,db) result = legis_funcs.runModel(model,bill) if result[0] == 1: the_result = "PASS" if result[0] == 0: the_result = "FAIL" data['the_result'] = the_result the_confidence = legis_funcs.modelConf(model,bill) data['the_confidence'] = the_confidence if the_result == "PASS": img_file = 'glyphicon-ok' img_color = 'green' if the_result == "FAIL": img_file = 'glyphicon-remove' img_color = 'red' data['img_file'] = img_file data['img_color'] = img_color funding_tup = legis_funcs.retrieveFunding(bill_type,bill_number,congress,db) data['funding_tup'] = funding_tup legis_funcs.makeBarPlotFile(funding_tup,0) #for now just do the top ranked funder (rank = 0) top_ten_funders = list() for x in range(0,10): top_ten_funders.append(funding_tup[0][x][1]) #the names of the top 10 contributors. data['top_ten_funders'] = top_ten_funders with open('legislatr/static/'+json_name+'.p','wb') as fp: pickle.dump(data,fp) return render_template("output.html",the_result = the_result, the_confidence = int(round(the_confidence)), funders = top_ten_funders, img_file = img_file, img_color = img_color, bill_title = title, bill_type=bill_type, bill_number=bill_number, congress=congress, data_file=json_name)
def legislatr_inputSearch2(): ind = int(request.args.get('user_choice')) json_name = request.args.get('data_file') with open('legislatr/static/'+json_name+'.p','rb') as fp: data = pickle.load(fp) options = data["options"] option = options[ind] query_db = data["query_db"] congress = query_db["congress"].iloc[ind] bill_type = query_db["bill_type"].iloc[ind] bill_number = query_db["bill_number"].iloc[ind] title = legis_funcs.retrieveTitle(bill_type,bill_number,congress,db) data['title'] = title data['bill_type'] = bill_type data['bill_number'] = bill_number data['congress'] = congress with open('legislatr/static/'+json_name+'.p','wb') as fp: pickle.dump(data,fp) return render_template("inputSearch2.html", bill_choice=ind, congress=congress, bill_type=bill_type,bill_number=bill_number,bill_title=title,bill_options=options,data_file=json_name)
def legislatr_inputSearch2(): ind = int(request.args.get('user_choice')) options = app.var["options"] option = options[ind] query_db = app.var["query_db"] congress = query_db["congress"].iloc[ind] bill_type = query_db["bill_type"].iloc[ind] bill_number = query_db["bill_number"].iloc[ind] title = legis_funcs.retrieveTitle(bill_type, bill_number, congress, db) app.var['title'] = title app.var['bill_type'] = bill_type app.var['bill_number'] = bill_number app.var['congress'] = congress return render_template("inputSearch2.html", bill_choice=ind, congress=congress, bill_type=bill_type, bill_number=bill_number, bill_title=title, bill_options=options)