@@ -335,6 +335,33 @@ public SemgrexMatcher matcher(SemanticGraph hypGraph, Alignment alignment, Seman
335
335
return matcher (hypGraph , alignment , txtGraph , true , hypGraph .getFirstRoot (), new LinkedHashMap <>(), new LinkedHashMap <>(), new LinkedHashMap <>(), new VariableStrings (), ignoreCase );
336
336
}
337
337
338
+ // batch processing
339
+ // -------------------------------------------------------------
340
+
341
+ /**
342
+ * Returns a list of matching sentences and each of the matches from those sentences.
343
+ *<br>
344
+ * Non-matching sentences are currently not returned (may change in the future to return an empty list).
345
+ */
346
+ public List <Pair <CoreMap , List <SemgrexMatch >>> matchSentences (List <CoreMap > sentences ) {
347
+ List <Pair <CoreMap , List <SemgrexMatch >>> matches = new ArrayList <>();
348
+ for (CoreMap sentence : sentences ) {
349
+ SemanticGraph graph = sentence .get (SemanticGraphCoreAnnotations .BasicDependenciesAnnotation .class );
350
+ SemanticGraph enhanced = sentence .get (SemanticGraphCoreAnnotations .EnhancedDependenciesAnnotation .class );
351
+ SemgrexMatcher matcher = matcher (graph );
352
+ if ( ! matcher .find ()) {
353
+ continue ;
354
+ }
355
+ matches .add (new Pair <>(sentence , new ArrayList <>()));
356
+ boolean found = true ;
357
+ while (found ) {
358
+ matches .get (matches .size () - 1 ).second ().add (new SemgrexMatch (this , matcher ));
359
+ found = matcher .find ();
360
+ }
361
+ }
362
+ return matches ;
363
+ }
364
+
338
365
// compile method
339
366
// -------------------------------------------------------------
340
367
@@ -444,30 +471,6 @@ public enum OutputFormat {
444
471
CONLLU
445
472
}
446
473
447
- /**
448
- * Returns a list of matching sentences and each of the matches from those sentences.
449
- *<br>
450
- * Non-matching sentences are currently not returned (may change in the future to return an empty list).
451
- */
452
- public List <Pair <CoreMap , List <SemgrexMatch >>> matchSentences (List <CoreMap > sentences ) {
453
- List <Pair <CoreMap , List <SemgrexMatch >>> matches = new ArrayList <>();
454
- for (CoreMap sentence : sentences ) {
455
- SemanticGraph graph = sentence .get (SemanticGraphCoreAnnotations .BasicDependenciesAnnotation .class );
456
- SemanticGraph enhanced = sentence .get (SemanticGraphCoreAnnotations .EnhancedDependenciesAnnotation .class );
457
- SemgrexMatcher matcher = matcher (graph );
458
- if ( ! matcher .find ()) {
459
- continue ;
460
- }
461
- matches .add (new Pair <>(sentence , new ArrayList <>()));
462
- boolean found = true ;
463
- while (found ) {
464
- matches .get (matches .size () - 1 ).second ().add (new SemgrexMatch (this , matcher ));
465
- found = matcher .find ();
466
- }
467
- }
468
- return matches ;
469
- }
470
-
471
474
private static final String PATTERN = "-pattern" ;
472
475
private static final String TREE_FILE = "-treeFile" ;
473
476
private static final String MODE = "-mode" ;
0 commit comments