''' Brett Paufler START: 2020-07-19 FINISH: NOPE ABANDONED: 2021-04-26 An Abandoned Script whereby it was hoped to extract Graphs and such from 2019_01 & 2019_02 of Judging The Judges ''' ############################ # # CASE: NamedTuple # ############################ from collections import namedtuple BP_OPINION = namedtuple( 'BP_OPINION', ['id', 'agree', 'text_list' ]) #print BP_OPINION ############################## # # HTML to List of Case Data # ############################## file_in = "./input/2019_01.html" with open(file_in, 'r') as f: html_text = f.read() #print html_text #I added the second file, right before abandonment file_in = "./input/2019_02.html" with open(file_in, 'r') as f: html_text += f.read() w_list = html_text.split('

') #print len(w_list)#, w_list w_list = w_list[1:] #print len(w_list)# , w_list w_list = [w.split('

')[0] for w in w_list] #print len(w_list)#, w_list CASES = [] for w in w_list: #print w #Scrubbing The Input w = w.replace('
', '') w = w.replace('', '') w = w.replace('', '') w = w.replace('', '') w = w.replace('', '') #print w #We Have [id, agree, [text_list] w = w.split('\n') w = [u for u in w if u != ''] #print w #Splitting it Up w_id = w.pop(0) w_agree = w.pop(0) #print w_id, w_agree, w this_opinion = BP_OPINION(w_id, w_agree, w) CASES.append (this_opinion) #HTML Has Been Reduced to a CASES Object #CASES = [BP_OPINION, BP_OPINION] #print len(CASES) #for c in CASES: # print c num_cases = len(CASES) #print num_cases #47 ######################################### ######################################### # START GRAPHICAL OUTPUT ######################################### ######################################### ####################################### # # Color Band Agreement Images # ################################### import numpy as np from skimage.io import imsave agree_num_list = [] for c in CASES: #print c.agree #Because This Wasn't The Case Before This Check assert c.agree in ['Good', 'Bad', 'Neutral'] if c.agree == 'Bad': this_agree = 0.0 elif c.agree == 'Neutral': this_agree = 0.5 elif c.agree == 'Good': this_agree = 1.0 agree_num_list.append(this_agree) color = np.array(agree_num_list) white = np.array([agree_num_list]) zero = np.zeros_like(color) save_name = "./output/1902_02_agree.png" imsave(save_name, white) img = np.dstack((color, zero, zero)) save_name = "./output/1902_02_agree_red.png" imsave(save_name, img) img = np.dstack((zero, color, zero)) save_name = "./output/1902_02_agree_green.png" imsave(save_name, img) img = np.dstack((zero, zero, color)) save_name = "./output/1902_02_agree_blue.png" imsave(save_name, img) # # # # # # # # # # # # # # # Agree Bar Graph # # # # # # # # # # # # # # import matplotlib.pyplot as plt bar_data = 2*color - 1 #print bar_data #Output Graph #Will Trim in Photo Editor plt.subplots(figsize=(15,5)) plt.plot(range(len(bar_data)), bar_data) #plt.show() plt.savefig('./output/2019_02_agree_graph_cuttable.png') plt.clf() ######################################### # # Numeric Output: Saved To Text File # ######################################### text = '' ''' For Reference Cut at ENd #Output Graph plt.subplots(figsize=(15,5)) plt.plot(range(len(bar_data)), bar_data) #bar(x_div, num_opin)#, color='black') #plt.xticks(x_div, judges) #plt.ylabel('Number of Opinions Authored') #plt.title('Supreme Court\n2018 Term Year') #plt.show() plt.savefig('./output/2019_02_agree_graph_cuttable.png') plt.clf() '''