Heiko Hotz commited on
Commit
834345a
1 Parent(s): 834de5e

initial commit

Browse files
Files changed (2) hide show
  1. app.py +22 -5
  2. data/questions_short.txt +41 -0
app.py CHANGED
@@ -19,6 +19,18 @@ def load_questions():
19
  return questions
20
 
21
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  st.cache(show_spinner=False, persist=True)
23
 
24
 
@@ -34,6 +46,7 @@ def load_contracts():
34
 
35
 
36
  questions = load_questions()
 
37
  # contracts = load_contracts()
38
 
39
  ### DEFINE SIDEBAR
@@ -83,7 +96,7 @@ if user_upload is not None:
83
  pdfReader = PyPDF4.PdfFileReader(user_upload)
84
  print(pdfReader.numPages)
85
  contract_data = ''
86
- for i in range(0,pdfReader.numPages):
87
 
88
  print(i)
89
  pageobj = pdfReader.getPage(i)
@@ -106,9 +119,12 @@ number_results = st.sidebar.selectbox('Select number of results', results_drop)
106
  st.header("Legal Contract Review Demo")
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'):
114
  if (not len(paragraph)==0) and not (len(question)==0):
@@ -116,8 +132,8 @@ if st.button('Analyze'):
116
  with st.spinner(text='Analysis in progress...'):
117
  #predictions = run_prediction([question], paragraph, '../models/roberta-base/')
118
  data = {}
119
- data['question']=[question]
120
- data['context']=paragraph
121
  print(data)
122
 
123
  predictions = run_prediction(data['question'], data['context'], 'akdeniz27/roberta-base-cuad',
@@ -135,5 +151,6 @@ if st.button('Analyze'):
135
  f = open("nbest.json")
136
  st.success(f.readlines())
137
  st.success("Successfully processed contract!")
 
138
  else:
139
  st.write("Unable to call model, please select question and contract")
 
19
  return questions
20
 
21
 
22
+ def load_questions_short():
23
+ questions_short = []
24
+ with open('data/questions_short.txt') as f:
25
+ questions_short = f.readlines()
26
+
27
+ # questions = []
28
+ # for i, q in enumerate(data['data'][0]['paragraphs'][0]['qas']):
29
+ # question = data['data'][0]['paragraphs'][0]['qas'][i]['question']
30
+ # questions.append(question)
31
+ return questions_short
32
+
33
+
34
  st.cache(show_spinner=False, persist=True)
35
 
36
 
 
46
 
47
 
48
  questions = load_questions()
49
+ questions_short = load_questions_short()
50
  # contracts = load_contracts()
51
 
52
  ### DEFINE SIDEBAR
 
96
  pdfReader = PyPDF4.PdfFileReader(user_upload)
97
  print(pdfReader.numPages)
98
  contract_data = ''
99
+ for i in range(0, pdfReader.numPages):
100
 
101
  print(i)
102
  pageobj = pdfReader.getPage(i)
 
119
  st.header("Legal Contract Review Demo")
120
  st.write("This demo uses the CUAD dataset for Contract Understanding.")
121
 
122
+ paragraph = st.text_area(label="Contract", value=contract_data, height=300)
123
 
124
+ questions_drop = questions_short
125
+ question_short = st.selectbox('Choose one of the 41 queries from the CUAD dataset:', questions_drop)
126
+ idxq = questions_drop.index(contract)
127
+ question = questions[idxq]
128
 
129
  if st.button('Analyze'):
130
  if (not len(paragraph)==0) and not (len(question)==0):
 
132
  with st.spinner(text='Analysis in progress...'):
133
  #predictions = run_prediction([question], paragraph, '../models/roberta-base/')
134
  data = {}
135
+ data['question'] = [question]
136
+ data['context'] = paragraph
137
  print(data)
138
 
139
  predictions = run_prediction(data['question'], data['context'], 'akdeniz27/roberta-base-cuad',
 
151
  f = open("nbest.json")
152
  st.success(f.readlines())
153
  st.success("Successfully processed contract!")
154
+ st.success(question)
155
  else:
156
  st.write("Unable to call model, please select question and contract")
data/questions_short.txt ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Question 1: What is the contract name?
2
+ Question 2: Who are the parties that signed the contract?
3
+ Question 3: What is the agreement date of the contract?
4
+ Question 4: What is the date when the contract is effective?
5
+ Question 5: What date will the contract's initial term expire?
6
+ Question 6: What is the renewal term after the initial term expires?
7
+ Question 7: What is the notice period required to terminate renewal?
8
+ Question 8: Which state/country's law governs the interpretation of the contract?
9
+ Question 9: Is there a clause that if a third party gets better terms in the contract, the buyer under the contract shall be entitled to those better terms?
10
+ Question 10: What is the restriction on the ability of a party to compete with the counterparty or operate in a certain geography or business or technology sector? 
11
+ Question 11: Is there an exclusive dealing  commitment with the counterparty?
12
+ Question 12: Is a party restricted from contracting or soliciting customers or partners of the counterparty, whether during the contract or after the contract ends (or both)?
13
+ Question 13: What are the competitive restriction exceptions in the contract?
14
+ Question 14: Is there a restriction on a party’s soliciting or hiring employees and/or contractors from the  counterparty, whether during the contract or after the contract ends (or both)?
15
+ Question 15: Is there a requirement on a party not to disparage the counterparty?
16
+ Question 16: Can a party terminate this  contract without cause (solely by giving a notice and allowing a waiting  period to expire)?
17
+ Question 17: What are the terms granting one party a right of first refusal, right of first offer, or right of first negotiation?
18
+ Question 18: What are the terms about right of termination?
19
+ Question 19: Is consent or notice required of a party if the contract is assigned to a third party?
20
+ Question 20: Is one party required to share revenue or profit with the counterparty for any technology, goods, or services?
21
+ Question 21: Is there a restriction on the  ability of a party to raise or reduce prices of technology, goods, or  services provided?
22
+ Question 22: Is there a minimum order size or minimum amount or units per-time period that one party must buy from the counterparty under the contract?
23
+ Question 23: Is there a fee increase or consent requirement, etc. if one party’s use of the product/services exceeds certain threshold?
24
+ Question 24: What are the terms about intellectual property created  by one party?
25
+ Question 25: Is there any clause providing for joint or shared ownership of intellectual property between the parties to the contract?
26
+ Question 26: Does the contract contain a license granted by one party to its counterparty?
27
+ Question 27: Does the contract limit the ability of a party to transfer the license being granted to a third party?
28
+ Question 28: Does the contract contain a license grant by affiliates of the licensor or that includes intellectual property of affiliates of the licensor? 
29
+ Question 29: Does the contract contain a license grant to a licensee (incl. sublicensor) and the affiliates of such licensee/sublicensor?
30
+ Question 30: Is there a clause granting one party an “enterprise,” “all you can eat” or unlimited usage license?
31
+ Question 31: Does the contract contain a  license grant that is irrevocable or perpetual?
32
+ Question 32: Is one party required to deposit its source code into escrow with a third party, which can be released to the counterparty upon the occurrence of certain events (bankruptcy,  insolvency, etc.)?
33
+ Question 33: Is a party subject to obligations after the termination or expiration of a contract, including any post-termination transition, payment, transfer of IP, wind-down, last-buy, or similar commitments?
34
+ Question 34: Does a party have the right to  audit the books, records, or physical locations of the counterparty to ensure compliance with the contract?
35
+ Question 35: Is a party’s liability uncapped upon the breach of its obligation in the contract? This also includes uncap liability for a particular type of breach such as IP infringement or breach of confidentiality obligation.
36
+ Question 36: Does the contract include a cap on liability upon the breach of a party’s obligation? This includes time limitation for the counterparty to bring claims or maximum amount for recovery.
37
+ Question 37: Does the contract contain a clause that would award either party liquidated damages for breach or a fee upon the termination of a contract (termination fee)?
38
+ Question 38: What is the duration of any  warranty against defects or errors in technology, products, or services  provided under the contract?
39
+ Question 39: Is there a requirement for insurance that must be maintained by one party for the benefit of the counterparty?
40
+ Question 40: Is a party restricted from contesting the validity of the counterparty’s ownership of intellectual property or otherwise bringing a claim against the counterparty for matters unrelated to the contract?
41
+ Question 41: Is there a non-contracting party who is a beneficiary to some or all of the clauses in the contract and therefore can enforce its rights against a contracting party?