Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9711192

Browse files
committed
A basic test of a regex match
1 parent9e2ff5c commit9711192

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎test/src/edu/stanford/nlp/semgraph/semgrex/SemgrexTest.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,16 +1573,24 @@ public void testBatchUniq() {
15731573
}
15741574

15751575
publicvoidtestVariableGroups() {
1576+
// first, a basic test that it is capturing the variable groups correctly
15761577
SemgrexPatternpattern =SemgrexPattern.compile("{word:/(.*ill.*)/#1%name}");
15771578
SemanticGraphgraph =SemanticGraph.valueOf("[ate-2 subj> Bill-1 obj>[muffins-5 compound> Blueberry-3 compound> filled-4]]");
15781579
Set<String>matches =newHashSet<>();
15791580
SemgrexMatchermatcher =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
publicstaticvoidoutputBatchResults(SemgrexPatternpattern,List<CoreMap>sentences) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp