-
Notifications
You must be signed in to change notification settings - Fork 1
/
legalese.py
125 lines (117 loc) · 3.42 KB
/
legalese.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
""" A function to iterate through a legal document and replace it with plain
English
Things to do:
-highlight legalese that is replaced with English
-accept pdf and ms word docs
-better way to make dictionary not case sensitive, as opposed to making the
search case insensitive.
"""
import re
# user inputs the document they want translated
text = raw_input("Please type the full path of the document you want translated from legalese to plain english. >>>")
#text = '/Users/michaelchan/Desktop/legalsample.txt'
# document is read
text = open(text).read()
print "This is the original text..."
print text
print '\n'
print "Now, here is the new text with out legalese.."
print '\n'
#dictionary of useless legal terms
legal_dict = {'ab initio':'from the start',
'accord': 'give',
'afforded':'given',
'aforementioned':'this',
'aforesaid': 'this',
'albeit':'although' ,
'ambit':'scope',
'antecedent to':'before',
'as a means of': 'to',
'as prescribed by': 'under',
'aver':'state',
'bona fide': 'good faith',
'case at bar':'this case',
'case sub judice':'this case',
'cease':'stop',
'circa':'about',
'commence': 'start',
'defacto': 'in reality',
'envisage': 'see',
'ex post facto': 'retrospectively',
'hence': 'from now on',
'henceforth':'from now on',
'henceforward': 'from now on',
'herein': 'in this document/paragraph/sentence',
'hereto': 'in this document/paragraph/sentence',
'heretofore':'until now',
'hitherto': 'until now',
'in a case in which':'when / where',
'in accordance with': 'under',
'in as much as':'because',
'in excess of': 'more than',
'in lieu of':'instead of',
'in order to':'to',
'in receipt of':'have',
'in reference to': 'about',
'in regard to': 'about',
'in the amount of': 'for',
'in the event of that' :'if',
'in the event that':'if',
'in the near future':'soon',
'inter alia':'among other things',
'inter partes':'between parties',
'inter se': 'among themselves',
'in toto': 'entirely',
'ipso facto':'therefore',
'it is apparent that':'clearly',
'mutatis mutandis': 'things that must be changed',
'notwithstanding':'despite',
'null and void':'void',
'pertaining to':'about/of',
'precis':'summary',
'prima facie':'on the face of it',
'on behalf of': 'for',
'on the part of':'by',
'post hoc':'after this',
'pursuant': 'required',
'remainder':'rest',
'requisite':'required',
'retain':'keep',
'simultaneously':'at the same time',
'subsequent':'later',
'subsequent to':'after',
'subsequently': 'afterwards',
'substantiate': 'prove',
'take into consideration':'consider',
'the case at bar':'this case',
'the fact that':'that',
'the instant case': 'this case',
'the majority of':'most',
'the manner in which':'how',
'thereafter': 'from that',
'therein':'in there',
'thereof': 'of it',
'theretofore':'until then',
'thereupon':'then',
'thitherto':'until then',
'until such time as':'until',
'unto': 'to',
'upon':'on',
'utilize':'use',
'whence':'from where',
'whereas': 'This contract is made with reference to the following facts',
'whereat':'where',
'wherein':'where',
'with regard to':'about',
'with the exception of':'except for',
'witnesseth':'this agreement shows/between',
}
# Using a case insensitive search for legalese as opposed to a case insensitive dictionary. Have to import regular expressions.
def replace(legal_dict,text):
keys = legal_dict.keys()
for i in keys:
exp = re.compile(i, re.I)
text = re.sub(exp, legal_dict[i], text)
return text
text = replace(legal_dict,text)
print text