|
@@ -1,45 +1,213 @@
|
1
|
1
|
package graph.extractor.graph.builder;
|
2
|
2
|
|
3
|
|
-import entity.DOProcess;
|
4
|
|
-import entity.Entity;
|
5
|
|
-import entity.Judge;
|
6
|
|
-import entity.Lawyer;
|
7
|
|
-import entity.ProcessTypes;
|
8
|
|
-import entity.TYPES;
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+import dao.entity.DOProcess;
|
|
6
|
+import dao.entity.Entity;
|
|
7
|
+import dao.entity.Judge;
|
|
8
|
+import dao.entity.Lawyer;
|
|
9
|
+import dao.entity.ProcessTypes;
|
|
10
|
+import dao.entity.TYPES;
|
9
|
11
|
|
10
|
12
|
public class STJBuilder extends BuilderFactory{
|
11
|
13
|
|
|
14
|
+ private static boolean nextLawyer =false;
|
|
15
|
+
|
|
16
|
+ private String normalizeJudgeName(String judgeName)
|
|
17
|
+ {
|
|
18
|
+
|
|
19
|
+ if(judgeName.contains("(") && !judgeName.startsWith("(") )
|
|
20
|
+ {
|
12
|
21
|
|
|
22
|
+ try{
|
13
|
23
|
|
14
|
|
- private Entity getEntity(String canditate)
|
|
24
|
+ judgeName = judgeName.split("\\(")[0].trim();
|
|
25
|
+ }catch(Exception e)
|
|
26
|
+ {
|
|
27
|
+ e.printStackTrace();
|
|
28
|
+ }
|
|
29
|
+ }
|
|
30
|
+ if(judgeName.contains("PRESIDENTE DA"))
|
|
31
|
+ {
|
|
32
|
+
|
|
33
|
+ judgeName = TYPES.NAMEDEFAULT;
|
|
34
|
+ }
|
|
35
|
+ if(judgeName.equals("PROCESSO NÃO DISTRIBUÍDO"))
|
|
36
|
+ {
|
|
37
|
+ judgeName = TYPES.NAMEDEFAULT;
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+ return judgeName;
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+ private String normalizeEntityName(String entityName)
|
15
|
46
|
{
|
16
|
|
- Entity entity = new Entity();
|
|
47
|
+ String originalEntityName = entityName.trim();
|
|
48
|
+
|
|
49
|
+ if(entityName.contains("(PRESO)"))
|
|
50
|
+ {
|
|
51
|
+ entityName = entityName.split("(PRESO)")[0].trim();
|
|
52
|
+ }
|
|
53
|
+ if(entityName.contains("E OUTRO"))
|
|
54
|
+ {
|
|
55
|
+ entityName = entityName.split("E OUTRO")[0].trim();
|
|
56
|
+ }
|
|
57
|
+ if(entityName.endsWith(" E"))
|
|
58
|
+ {
|
|
59
|
+ entityName = entityName.split(" E")[0].trim();
|
|
60
|
+ }
|
|
61
|
+ if(entityName.endsWith("\\("))
|
|
62
|
+ {
|
|
63
|
+ entityName = entityName.split("\\(")[0].trim();
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+ if(entityName.length() > 0)
|
|
68
|
+ return entityName;
|
|
69
|
+ else
|
|
70
|
+ return TYPES.NAMEDEFAULT;
|
|
71
|
+
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+ private Lawyer normalizeLawyerName(Lawyer lawyer)
|
|
76
|
+ {
|
|
77
|
+
|
|
78
|
+ //String originalEntityName = entityName.trim();
|
|
79
|
+ String nameNormalized = lawyer.getName().replaceAll("\\r|\\n", " ").trim();
|
|
80
|
+
|
17
|
81
|
|
18
|
82
|
try{
|
|
83
|
+
|
|
84
|
+
|
19
|
85
|
|
|
86
|
+ if(nameNormalized.contains("-"))
|
|
87
|
+ {
|
20
|
88
|
|
|
89
|
+ if(nameNormalized.charAt(nameNormalized.length()-1) != '-')
|
|
90
|
+ {
|
|
91
|
+ lawyer.setOABNumber(nameNormalized.split("-")[1].trim());
|
|
92
|
+ }
|
|
93
|
+ nameNormalized = nameNormalized.split("-")[0].trim();
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ if(nameNormalized.contains("E OUTRO"))
|
|
97
|
+ {
|
|
98
|
+ nameNormalized = nameNormalized.split("E OUTRO")[0].trim();
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ if(nameNormalized.contains("DEFENSORIA") ||nameNormalized.contains("PROCURADORIA"))
|
|
102
|
+ {
|
|
103
|
+ nameNormalized = TYPES.NAMEDEFAULT;
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+ }
|
|
108
|
+ catch(Exception e)
|
|
109
|
+ {
|
|
110
|
+
|
|
111
|
+ System.out.println("lawyer error: " + lawyer);
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+ if(nameNormalized.contains("EM CAUSA") )
|
|
120
|
+ {
|
|
121
|
+ nameNormalized = nameNormalized.split("EM CAUSA")[0].trim();
|
|
122
|
+ nameNormalized = nameNormalized.substring(0, nameNormalized.length() -1).trim();
|
|
123
|
+
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ if(nameNormalized.equals("E OUTRO(S)"))
|
|
127
|
+ {
|
|
128
|
+ nameNormalized = TYPES.NAMEDEFAULT;
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+ if(nameNormalized.endsWith(" E"))
|
|
133
|
+ {
|
|
134
|
+ nameNormalized = nameNormalized.split(" E")[0].trim();
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ if(nameNormalized.equals(""))
|
|
138
|
+ {
|
|
139
|
+ lawyer.setName(lawyer.getName());
|
|
140
|
+ }
|
|
141
|
+ else
|
|
142
|
+ {
|
|
143
|
+ lawyer.setName(nameNormalized);
|
|
144
|
+ }
|
|
145
|
+
|
|
146
|
+ return lawyer;
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+ }
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+ private Entity getEntity(String canditate)
|
|
156
|
+ {
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+ Entity entity = new Entity();
|
|
161
|
+
|
|
162
|
+ try{
|
|
163
|
+
|
|
164
|
+
|
21
|
165
|
if(canditate.contains(":") && !canditate.contains("Distribuição automática"))
|
22
|
166
|
{
|
23
|
167
|
String type = canditate.split(":")[0].trim();
|
24
|
168
|
entity.setType(type);
|
|
169
|
+ entity.setName(this.normalizeEntityName(canditate.split(":")[1].trim()));
|
25
|
170
|
|
26
|
171
|
|
27
|
172
|
if(type.equals("RELATORA") || type.equals("RELATOR"))
|
28
|
173
|
{
|
29
|
174
|
entity.setType(TYPES.JUDGE);
|
|
175
|
+ entity.setName(this.normalizeJudgeName(canditate.split(":")[1].trim()));
|
|
176
|
+
|
|
177
|
+
|
30
|
178
|
}
|
31
|
|
- if(type.contains("ADVOGAD") )
|
|
179
|
+ if(type.contains("ADVOGAD") || type.contains("PROCURADOR") )
|
32
|
180
|
{
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+ entity = this.normalizeLawyerName(new Lawyer(canditate.split(":")[1].trim()) );
|
33
|
184
|
entity.setType(TYPES.LAWYER);
|
|
185
|
+ if(type.contains("ADVOGADOS") )
|
|
186
|
+ nextLawyer = true;
|
|
187
|
+
|
34
|
188
|
}
|
35
|
189
|
|
36
|
|
- entity.setName(canditate.split(":")[1].trim());
|
|
190
|
+
|
37
|
191
|
|
38
|
192
|
}
|
39
|
193
|
else
|
40
|
194
|
{
|
41
|
|
- entity.setName(canditate);
|
42
|
|
- entity.setType(TYPES.OTHERINFO);
|
|
195
|
+ if(nextLawyer)
|
|
196
|
+ {
|
|
197
|
+ nextLawyer = false;
|
|
198
|
+ entity.setType(TYPES.LAWYER);
|
|
199
|
+ entity.setName(canditate);
|
|
200
|
+
|
|
201
|
+ }
|
|
202
|
+ else{
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+ entity.setName(canditate);
|
|
206
|
+ entity.setType(TYPES.OTHERINFO);
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
43
|
211
|
|
44
|
212
|
|
45
|
213
|
}
|
|
@@ -57,11 +225,25 @@ public class STJBuilder extends BuilderFactory{
|
57
|
225
|
@Override
|
58
|
226
|
protected DOProcess extractProcess(String process) {
|
59
|
227
|
|
60
|
|
-
|
|
228
|
+
|
61
|
229
|
DOProcess proc = new DOProcess();
|
62
|
|
-
|
|
230
|
+
|
|
231
|
+// try{
|
|
232
|
+// File file = new File("/home/ailton/Monografia/log");
|
|
233
|
+// FileWriter fileWriter = new FileWriter(file, true);
|
|
234
|
+// PrintWriter out = new PrintWriter(fileWriter);
|
|
235
|
+// out.println(process);
|
|
236
|
+// out.println();
|
|
237
|
+// out.close();
|
|
238
|
+//
|
|
239
|
+// }catch(Exception e)
|
|
240
|
+// {
|
|
241
|
+// e.printStackTrace();
|
|
242
|
+// }
|
|
243
|
+
|
|
244
|
+
|
63
|
245
|
proc.setOrign("DJ_STJ");
|
64
|
|
-
|
|
246
|
+
|
65
|
247
|
String vecProcesses[] = process.split("\n");
|
66
|
248
|
int index = 0;
|
67
|
249
|
String firstLine = vecProcesses[index];
|
|
@@ -78,24 +260,24 @@ public class STJBuilder extends BuilderFactory{
|
78
|
260
|
{
|
79
|
261
|
index++;
|
80
|
262
|
firstLine = firstLine +vecProcesses[index];
|
81
|
|
-
|
|
263
|
+
|
82
|
264
|
}
|
83
|
|
-
|
|
265
|
+
|
84
|
266
|
if(!firstLine.contains("class='np'"))
|
85
|
267
|
{
|
86
|
268
|
return null;
|
87
|
|
-
|
|
269
|
+
|
88
|
270
|
}
|
89
|
|
-
|
90
|
|
-
|
|
271
|
+
|
|
272
|
+
|
91
|
273
|
|
92
|
274
|
String processType = firstLine.toLowerCase().split("nº")[0].toLowerCase();
|
93
|
275
|
firstLine = firstLine.substring(processType.length());
|
94
|
276
|
ProcessTypes procType = new ProcessTypes(processType);
|
95
|
277
|
proc.setProcessType(procType);
|
96
|
|
-
|
97
|
|
-
|
98
|
|
-
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
99
|
281
|
String processIndex = firstLine.split("<NP1><B class='np'>")[0].trim();
|
100
|
282
|
firstLine = firstLine.split("<NP1><B class='np'>")[1].trim();
|
101
|
283
|
proc.setProcessIndex(processIndex);
|
|
@@ -147,33 +329,38 @@ public class STJBuilder extends BuilderFactory{
|
147
|
329
|
}
|
148
|
330
|
|
149
|
331
|
|
150
|
|
-
|
|
332
|
+
|
151
|
333
|
/***next lines*/
|
152
|
334
|
try{
|
153
|
335
|
index++;
|
154
|
|
-
|
|
336
|
+
|
155
|
337
|
String line = vecProcesses[index];
|
156
|
338
|
|
157
|
339
|
while( index < vecProcesses.length-1 && !this.isVerdict(line) )
|
158
|
340
|
{
|
159
|
341
|
|
160
|
342
|
Entity entity= this.getEntity(line);
|
161
|
|
- switch (entity.getType()) {
|
162
|
|
- case TYPES.JUDGE:
|
163
|
|
- proc.setJudge(new Judge(entity.getName()));
|
164
|
|
- break;
|
165
|
|
- case TYPES.OTHERINFO:
|
166
|
|
- proc.addOtherInfo(entity.getName());
|
167
|
|
- break;
|
168
|
|
- case TYPES.LAWYER:
|
169
|
|
- proc.addLawyer(new Lawyer(entity.getName()));
|
170
|
|
- break;
|
171
|
|
-
|
172
|
|
-
|
173
|
|
- default:
|
174
|
|
- proc.addEntity(entity);
|
175
|
|
- break;
|
|
343
|
+
|
|
344
|
+ if(entity.getName() != null)
|
|
345
|
+ {
|
|
346
|
+ switch (entity.getType()) {
|
|
347
|
+ case TYPES.JUDGE:
|
|
348
|
+ proc.setJudge(new Judge(entity.getName()));
|
|
349
|
+ break;
|
|
350
|
+ case TYPES.OTHERINFO:
|
|
351
|
+ proc.addOtherInfo(entity.getName());
|
|
352
|
+ break;
|
|
353
|
+ case TYPES.LAWYER:
|
|
354
|
+ proc.addLawyer(new Lawyer(entity.getName()));
|
|
355
|
+ break;
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+ default:
|
|
359
|
+ proc.addEntity(entity);
|
|
360
|
+ break;
|
|
361
|
+ }
|
176
|
362
|
}
|
|
363
|
+
|
177
|
364
|
|
178
|
365
|
index++;
|
179
|
366
|
line = vecProcesses[index];
|
|
@@ -204,7 +391,39 @@ public class STJBuilder extends BuilderFactory{
|
204
|
391
|
|
205
|
392
|
|
206
|
393
|
|
|
394
|
+ private double getLowerCasePCT(String line)
|
|
395
|
+ {
|
|
396
|
+ int lowerCaseLetters = 0;
|
|
397
|
+ for (int i = 0; i < line.length(); i++)
|
|
398
|
+ {
|
|
399
|
+ char ch = line.charAt(i);
|
|
400
|
+
|
|
401
|
+ //If ch is in lowercase, then incrementing lowerCaseLetters
|
|
402
|
+
|
|
403
|
+ if(Character.isLowerCase(ch))
|
|
404
|
+ {
|
|
405
|
+
|
|
406
|
+ lowerCaseLetters++;
|
|
407
|
+ }
|
|
408
|
+ }
|
|
409
|
+ if( line.length() > 0)
|
|
410
|
+ return 100*lowerCaseLetters/line.length();
|
|
411
|
+
|
|
412
|
+ return lowerCaseLetters;
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+ }
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
207
|
419
|
private boolean isVerdict(String line) {
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+ //System.out.println(line + " "+ this.getLowerCasePCT(line));
|
|
423
|
+
|
|
424
|
+ if(this.getLowerCasePCT(line) > 65)
|
|
425
|
+ return true;
|
|
426
|
+
|
208
|
427
|
line = line.trim().toLowerCase();
|
209
|
428
|
|
210
|
429
|
if(line.equals("despacho"))
|
|
@@ -217,7 +436,13 @@ public class STJBuilder extends BuilderFactory{
|
217
|
436
|
|
218
|
437
|
return true;
|
219
|
438
|
}
|
220
|
|
-
|
|
439
|
+ if(line.equals("ementa"))
|
|
440
|
+ {
|
|
441
|
+
|
|
442
|
+ return true;
|
|
443
|
+ }
|
|
444
|
+
|
|
445
|
+
|
221
|
446
|
if(line.contains("A Turma, por unanimidade"))
|
222
|
447
|
{
|
223
|
448
|
return true;
|