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() {
1573
1573
}
1574
1574
1575
1575
public void testVariableGroups () {
1576
+ // first, a basic test that it is capturing the variable groups correctly
1576
1577
SemgrexPattern pattern = SemgrexPattern .compile ("{word:/(.*ill.*)/#1%name}" );
1577
1578
SemanticGraph graph = SemanticGraph .valueOf ("[ate-2 subj> Bill-1 obj>[muffins-5 compound> Blueberry-3 compound> filled-4]]" );
1578
1579
Set <String > matches = new HashSet <>();
1579
1580
SemgrexMatcher matcher = pattern .matcher (graph );
1580
1581
while (matcher .find ()) {
1582
+ // TODO: check the size of the variableStrings here
1581
1583
assertNotNull (matcher .variableStrings .getString ("name" ));
1582
1584
matches .add (matcher .variableStrings .getString ("name" ));
1583
1585
}
1584
1586
Set <String > expectedMatches = Stream .of ("Bill" , "filled" ).collect (Collectors .toCollection (HashSet ::new ));
1585
1587
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 ());
1586
1594
}
1587
1595
1588
1596
public static void outputBatchResults (SemgrexPattern pattern , List <CoreMap > sentences ) {
You can’t perform that action at this time.
0 commit comments