@@ -335,6 +335,33 @@ public SemgrexMatcher matcher(SemanticGraph hypGraph, Alignment alignment, Seman
335335 return matcher (hypGraph , alignment , txtGraph , true , hypGraph .getFirstRoot (), new LinkedHashMap <>(), new LinkedHashMap <>(), new LinkedHashMap <>(), new VariableStrings (), ignoreCase );
336336 }
337337
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+
338365 // compile method
339366 // -------------------------------------------------------------
340367
@@ -444,30 +471,6 @@ public enum OutputFormat {
444471 CONLLU
445472 }
446473
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-
471474 private static final String PATTERN = "-pattern" ;
472475 private static final String TREE_FILE = "-treeFile" ;
473476 private static final String MODE = "-mode" ;
0 commit comments