File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
test/src/edu/stanford/nlp/semgraph/semgrex Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1573,16 +1573,24 @@ public void testBatchUniq() {
15731573 }
15741574
15751575 public void testVariableGroups () {
1576+ // first, a basic test that it is capturing the variable groups correctly
15761577 SemgrexPattern pattern = SemgrexPattern .compile ("{word:/(.*ill.*)/#1%name}" );
15771578 SemanticGraph graph = SemanticGraph .valueOf ("[ate-2 subj> Bill-1 obj>[muffins-5 compound> Blueberry-3 compound> filled-4]]" );
15781579 Set <String > matches = new HashSet <>();
15791580 SemgrexMatcher matcher = pattern .matcher (graph );
15801581 while (matcher .find ()) {
1582+ // TODO: check the size of the variableStrings here
15811583 assertNotNull (matcher .variableStrings .getString ("name" ));
15821584 matches .add (matcher .variableStrings .getString ("name" ));
15831585 }
15841586 Set <String > expectedMatches = Stream .of ("Bill" , "filled" ).collect (Collectors .toCollection (HashSet ::new ));
15851587 assertEquals (expectedMatches , matches );
1588+
1589+ pattern = SemgrexPattern .compile ("{word:/(.*)ill/#1%name} .. {word:/(.*)lueberry/#1%name}" );
1590+ matcher = pattern .matcher (graph );
1591+ assertTrue (matcher .find ());
1592+ assertEquals ("B" , matcher .variableStrings .getString ("name" ));
1593+ assertFalse (matcher .find ());
15861594 }
15871595
15881596 public static void outputBatchResults (SemgrexPattern pattern , List <CoreMap > sentences ) {
You can’t perform that action at this time.
0 commit comments