-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathconstants.py
268 lines (257 loc) · 6.21 KB
/
constants.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# Solr fields that are used for highlighting or other output in the search results
import re
from typing import Dict
from cl.search.models import SEARCH_TYPES, Opinion
SOLR_OPINION_HL_FIELDS = [
"caseName",
"citation",
"court_citation_string",
"docketNumber",
"judge",
"lexisCite",
"neutralCite",
"suitNature",
"text",
]
SOLR_PEOPLE_HL_FIELDS = ["name", "dob_city", "dob_state", "name_reverse"]
SOLR_PEOPLE_ES_HL_FIELDS = [
"name",
"name.exact",
"dob_city",
"dob_state_id",
"text",
"text.exact",
]
# ES fields that are used in the search queries
SEARCH_ORAL_ARGUMENT_QUERY_FIELDS = [
"court",
"court_citation_string",
"judge",
"dateArgued_text",
"dateReargued_text",
"dateReargumentDenied_text",
"court_id_text",
"sha1",
]
SEARCH_PEOPLE_CHILD_QUERY_FIELDS = [
"position_type",
"nomination_process",
"judicial_committee_action",
"selection_method",
"termination_reason",
"court_full_name",
"court_citation_string",
"court_exact",
"organization_name",
"job_title",
]
SEARCH_PEOPLE_PARENT_QUERY_FIELDS = [
"gender",
"alias",
"dob_city",
"political_affiliation",
"religion",
"fjc_id",
"aba_rating",
"school",
]
SEARCH_RECAP_CHILD_QUERY_FIELDS = [
"case_name_full",
"suitNature",
"juryDemand",
"cause",
"assignedTo",
"referredTo",
"court",
"court_id",
"court_citation_string",
"chapter",
"trustee_str",
"short_description",
"plain_text",
"document_type",
]
SEARCH_RECAP_PARENT_QUERY_FIELDS = [
"case_name_full",
"suitNature",
"cause",
"juryDemand",
"assignedTo",
"referredTo",
"court",
"court_id",
"court_citation_string",
"chapter",
"trustee_str",
]
SEARCH_OPINION_QUERY_FIELDS = [
"court",
"court_id",
"citation",
"judge",
"caseNameFull",
"caseName",
"status",
"suitNature",
"attorney",
"procedural_history",
"posture",
"syllabus",
]
# ES fields that are used for highlighting
SEARCH_HL_TAG = "mark"
ALERTS_HL_TAG = "strong"
SEARCH_ORAL_ARGUMENT_HL_FIELDS = [
"text",
"caseName",
"judge",
"docketNumber",
"court_citation_string",
]
SEARCH_ORAL_ARGUMENT_ES_HL_FIELDS = [
"caseName",
"caseName.exact",
"judge",
"judge.exact",
"docketNumber",
"docketNumber.exact",
"court_citation_string",
"text",
"text.exact",
]
SEARCH_ALERTS_ORAL_ARGUMENT_ES_HL_FIELDS = [
"text",
"text.exact",
"docketNumber",
"docketNumber.exact",
"judge",
"judge.exact",
]
SOLR_RECAP_HL_FIELDS = [
"assignedTo",
"caseName",
"cause",
"court_citation_string",
"docketNumber",
"juryDemand",
"referredTo",
"short_description",
"suitNature",
"text",
]
SEARCH_RECAP_HL_FIELDS = [
"assignedTo",
"caseName",
"cause",
"court_citation_string",
"docketNumber",
"juryDemand",
"referredTo",
"suitNature",
]
SEARCH_OPINION_HL_FIELDS = [
"caseName",
"citation",
"court_citation_string",
"docketNumber",
"suitNature",
]
# In RECAP Search, it is necessary to display 'plain_text' as a truncated snippet,
# where the snippet length is determined by 'fragment_size'.
# For all other fields, the complete content should be returned.
# To specify the 'fragment_size', set its value to 0 for no truncation,
# or provide a different integer to limit the snippet length.
SEARCH_RECAP_CHILD_HL_FIELDS = {
"short_description": 0,
"description": 0,
"plain_text": 100,
}
SEARCH_OPINION_CHILD_HL_FIELDS = {
"text": 100,
}
MULTI_VALUE_HL_FIELDS = ["citation"]
# Search query for related items
RELATED_PATTERN = re.compile(
r"""
(^|\s) # beginning of string or whitespace
(?P<pfx>related: # "related:" query prefix
(?P<pks>( # find related items for these IDs
([0-9]+)(,[0-9]+)* # one or more integers (comma separated)
)
)
)
($|\s) # end of string or whitespace
""",
re.VERBOSE,
)
# Search Boosts
recap_boosts_qf = {
"text": 1.0,
"caseName": 4.0,
"docketNumber": 3.0,
"description": 2.0,
}
recap_boosts_es = {
# Docket fields
"caseName": 4.0,
"docketNumber": 3.0,
# RECAPDocument fields:
"description": 2.0,
}
recap_boosts_pf = {"text": 3.0, "caseName": 3.0, "description": 3.0}
BOOSTS: Dict[str, Dict[str, Dict[str, float]]] = {
"qf": {
SEARCH_TYPES.OPINION: {
"text": 1.0,
"type": 1.0,
# Cluster fields
"caseName": 4.0,
"docketNumber": 2.0,
},
SEARCH_TYPES.RECAP: recap_boosts_qf,
SEARCH_TYPES.DOCKETS: recap_boosts_qf,
SEARCH_TYPES.ORAL_ARGUMENT: {
"text": 1.0,
"caseName": 4.0,
"docketNumber": 2.0,
},
SEARCH_TYPES.PEOPLE: {
# Was previously 4, but that had bad results for the name "William"
# due to Williams and Mary College.
"name": 8,
# Suppress these fields b/c a match on them returns the wrong
# person.
"appointer": 0.3,
"supervisor": 0.3,
"predecessor": 0.3,
},
},
"es": {
SEARCH_TYPES.RECAP: recap_boosts_es,
SEARCH_TYPES.DOCKETS: recap_boosts_es,
},
# Phrase-based boosts.
"pf": {
SEARCH_TYPES.OPINION: {"text": 3.0, "caseName": 3.0},
SEARCH_TYPES.RECAP: recap_boosts_pf,
SEARCH_TYPES.DOCKETS: recap_boosts_pf,
SEARCH_TYPES.ORAL_ARGUMENT: {"caseName": 3.0},
SEARCH_TYPES.PEOPLE: {
# None here. Phrases don't make much sense for people.
},
},
}
o_type_index_map = {
Opinion.COMBINED: "combined-opinion",
Opinion.UNANIMOUS: "unanimous-opinion",
Opinion.LEAD: "lead-opinion",
Opinion.PLURALITY: "plurality-opinion",
Opinion.CONCURRENCE: "concurrence-opinion",
Opinion.CONCUR_IN_PART: "in-part-opinion",
Opinion.DISSENT: "dissent",
Opinion.ADDENDUM: "addendum",
Opinion.REMITTUR: "remittitur",
Opinion.REHEARING: "rehearing",
Opinion.ON_THE_MERITS: "on-the-merits",
Opinion.ON_MOTION_TO_STRIKE: "on-motion-to-strike",
}