| import streamlit as st |
| import os |
| from bs4 import BeautifulSoup |
| import requests |
| |
| import pandas as pd |
| import boto3 |
| import json |
|
|
| aws_access_key = os.getenv("aws_access_key") |
| aws_secret_key = os.getenv("aws_secret_key") |
| s3 = boto3.client('s3', aws_access_key_id=aws_access_key, aws_secret_access_key=aws_secret_key) |
|
|
|
|
|
|
|
|
|
|
| st.set_page_config(layout="wide") |
|
|
| justices_response = s3.get_object(Bucket='gideon-corpus', Key='Justices Table.csv') |
| justices_df = pd.read_csv(justices_response['Body']) |
|
|
|
|
| def get_subdirectories(prefix): |
| subdirectories = set() |
| paginator = s3.get_paginator('list_objects_v2') |
| for result in paginator.paginate(Bucket="gideon-corpus", Prefix=prefix, Delimiter='/'): |
| if result.get('CommonPrefixes'): |
| subdirectories.update(subdir.get('Prefix') for subdir in result.get('CommonPrefixes')) |
| subdirectories = list(subdirectories) |
| subs = [s.split('/')[1] for s in subdirectories] |
| return subs |
|
|
| cases = get_subdirectories("Cases/") |
|
|
|
|
| for c in cases: |
| opinions_response = s3.get_object(Bucket='gideon-corpus', Key='Cases/' + c + '/opinions.csv') |
| opinions_df = pd.read_csv(opinions_response['Body']) |
|
|
|
|
| metadata_response = s3.get_object(Bucket='gideon-corpus', Key='Cases/' + c + '/metadata.json') |
| metadata = json.loads(metadata_response['Body'].read().decode('utf-8')) |
|
|
| |
| st.header(metadata['Case Name']) |
| st.subheader(metadata['Case Citation']) |
| st.subheader(metadata['Case Date']) |
| st.markdown("**" + metadata['Lower Court'] + "**") |
| |
| if metadata['Reverse']: |
| st.markdown("**:red[🔴Reversed🔴]**") |
| if metadata['Affirm']: |
| st.markdown("**:green[🟢Affirmed🟢]**") |
| if metadata['Vacate']: |
| st.markdown("**:orange[🟠Vacated🟠]**") |
| |
| types = opinions_df['Type'].tolist() |
| texts = opinions_df['Text'].tolist() |
| keywords = [eval(kws) for kws in opinions_df['Keywords'].tolist()] |
| author_inds = opinions_df['Author Ind'].tolist() |
| tabs = st.tabs(types) |
| for (tab, type, author_ind, text, kws) in zip(tabs, types, author_inds, texts, keywords): |
| with tab: |
| st.markdown("**" + justices_df.iloc[author_ind]['Name'].split(', ')[0].split(' ')[-1] + "**") |
| st.markdown("**Tags**: " + str(kws[0:6])) |
| |
| |
| |
| |
| |
| st.divider() |
| |
| |