Heiko Hotz commited on
Commit
834de5e
1 Parent(s): 5ad0224

initial commit

Browse files
Files changed (1) hide show
  1. app.py +3 -28
app.py CHANGED
@@ -1,32 +1,7 @@
1
- import collections
2
- import math
3
- import re
4
- import string
5
  import streamlit as st
6
- from transformers.pipelines import pipeline
7
- import json
8
- import sys
9
  from predict import run_prediction
10
- import random
11
  from io import StringIO
12
- import requests
13
- import boto3
14
-
15
- from transformers import (
16
- AutoConfig,
17
- AutoModelForQuestionAnswering,
18
- AutoTokenizer,
19
- squad_convert_examples_to_features
20
- )
21
-
22
- from transformers.data.processors.squad import SquadResult, SquadV2Processor, SquadExample
23
- from transformers.data.metrics.squad_metrics import compute_predictions_logits
24
-
25
- import gradio as gr
26
  import json
27
- import torch
28
- import time
29
- from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
30
 
31
  st.set_page_config(layout="wide")
32
  st.cache(show_spinner=False, persist=True)
@@ -82,7 +57,7 @@ contract = st.sidebar.selectbox('Please Select a Contract', contracts_drop)
82
 
83
 
84
  idx = contracts_drop.index(contract)
85
- with open('data/'+contracts_files[idx-1]) as f:
86
  contract_data = f.read()
87
 
88
  # upload contract
@@ -91,7 +66,7 @@ print(user_upload)
91
 
92
  # process upload
93
  if user_upload is not None:
94
- print(user_upload.name,user_upload.type)
95
  extension = user_upload.name.split('.')[-1].lower()
96
  if extension == 'txt':
97
  print('text file uploaded')
@@ -132,7 +107,7 @@ st.header("Legal Contract Review Demo")
132
  st.write("This demo uses the CUAD dataset for Contract Understanding.")
133
 
134
 
135
- paragraph = st.text_area(label="Contract",value=contract_data,height=400)
136
  question = st.selectbox('Choose one of the 41 queries from the CUAD dataset:', questions)
137
 
138
  if st.button('Analyze'):
 
 
 
 
 
1
  import streamlit as st
 
 
 
2
  from predict import run_prediction
 
3
  from io import StringIO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  import json
 
 
 
5
 
6
  st.set_page_config(layout="wide")
7
  st.cache(show_spinner=False, persist=True)
 
57
 
58
 
59
  idx = contracts_drop.index(contract)
60
+ with open('data/'+contracts_files[idx]) as f:
61
  contract_data = f.read()
62
 
63
  # upload contract
 
66
 
67
  # process upload
68
  if user_upload is not None:
69
+ print(user_upload.name, user_upload.type)
70
  extension = user_upload.name.split('.')[-1].lower()
71
  if extension == 'txt':
72
  print('text file uploaded')
 
107
  st.write("This demo uses the CUAD dataset for Contract Understanding.")
108
 
109
 
110
+ paragraph = st.text_area(label="Contract", value=contract_data, height=400)
111
  question = st.selectbox('Choose one of the 41 queries from the CUAD dataset:', questions)
112
 
113
  if st.button('Analyze'):