Skip to content

Commit c1dd698

Browse files
committed
Reverse the order of I->J so that tests looking at direction can be used with parents & children
1 parent 6558109 commit c1dd698

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

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

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ public void testReferencedRegex() {
227227
// TODO: implement referencing regexes
228228
}
229229

230+
/**
231+
* Make a fake graph with a bunch of random dependencies
232+
*<br>
233+
* All dependencies go from an earlier letter to a later letter except J to I.
234+
* Having at least one dependency go the other way allows for testing
235+
* of certain relationships involving direction
236+
*/
230237
public static SemanticGraph makeComplicatedGraph() {
231238
SemanticGraph graph = new SemanticGraph();
232239
String[] words = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
@@ -256,15 +263,15 @@ public static SemanticGraph makeComplicatedGraph() {
256263
UniversalEnglishGrammaticalRelations.ADJECTIVAL_MODIFIER, 1.0, false);
257264
graph.addEdge(nodes[4], nodes[6],
258265
UniversalEnglishGrammaticalRelations.ADVERBIAL_MODIFIER, 1.0, false);
259-
graph.addEdge(nodes[4], nodes[8],
266+
graph.addEdge(nodes[4], nodes[9],
260267
UniversalEnglishGrammaticalRelations.MODIFIER, 1.0, false);
261268
graph.addEdge(nodes[5], nodes[7],
262269
UniversalEnglishGrammaticalRelations.POSSESSION_MODIFIER, 1.0, false);
263270
graph.addEdge(nodes[6], nodes[7],
264271
UniversalEnglishGrammaticalRelations.CASE_MARKER, 1.0, false);
265-
graph.addEdge(nodes[7], nodes[8],
272+
graph.addEdge(nodes[7], nodes[9],
266273
UniversalEnglishGrammaticalRelations.AGENT, 1.0, false);
267-
graph.addEdge(nodes[8], nodes[9],
274+
graph.addEdge(nodes[9], nodes[8],
268275
UniversalEnglishGrammaticalRelations.DETERMINER, 1.0, false);
269276

270277
return graph;
@@ -284,14 +291,14 @@ public void testComplicatedGraph() {
284291
runTest("{} > {word:E}", graph,
285292
"B", "C", "D");
286293

287-
runTest("{} > {word:J}", graph,
288-
"I");
294+
runTest("{} > {word:I}", graph,
295+
"J");
289296

290297
runTest("{} < {word:E}", graph,
291-
"F", "G", "I");
298+
"F", "G", "J");
292299

293-
runTest("{} < {word:I}", graph,
294-
"J");
300+
runTest("{} < {word:J}", graph,
301+
"I");
295302

296303
runTest("{} << {word:A}", graph,
297304
"B", "C", "D", "E", "F", "G", "H", "I", "J");
@@ -317,10 +324,10 @@ public void testComplicatedGraph() {
317324
runTest("{} << {word:H}", graph,
318325
"I", "J");
319326

320-
runTest("{} << {word:I}", graph,
321-
"J");
327+
runTest("{} << {word:J}", graph,
328+
"I");
322329

323-
runTest("{} << {word:J}", graph);
330+
runTest("{} << {word:I}", graph);
324331

325332
runTest("{} << {word:K}", graph);
326333

@@ -344,11 +351,11 @@ public void testComplicatedGraph() {
344351
runTest("{} >> {word:H}", graph,
345352
"A", "B", "C", "D", "E", "F", "G");
346353

347-
runTest("{} >> {word:I}", graph,
354+
runTest("{} >> {word:J}", graph,
348355
"A", "B", "C", "D", "E", "F", "G", "H");
349356

350-
runTest("{} >> {word:J}", graph,
351-
"A", "B", "C", "D", "E", "F", "G", "H", "I");
357+
runTest("{} >> {word:I}", graph,
358+
"A", "B", "C", "D", "E", "F", "G", "H", "J");
352359

353360
runTest("{} >> {word:K}", graph);
354361
}
@@ -359,15 +366,15 @@ public void testRelationType() {
359366
"B", "E", "F", "G", "H", "I", "I", "J", "J");
360367

361368
runTest("{} >>det {}", graph,
362-
"A", "B", "C", "D", "E", "F", "G", "H", "I");
369+
"A", "B", "C", "D", "E", "F", "G", "H", "J");
363370

364-
runTest("{} >>det {word:J}", graph,
365-
"A", "B", "C", "D", "E", "F", "G", "H", "I");
371+
runTest("{} >>det {word:I}", graph,
372+
"A", "B", "C", "D", "E", "F", "G", "H", "J");
366373
}
367374

368375
public void testExactDepthRelations() {
369376
SemanticGraph graph = makeComplicatedGraph();
370-
runTest("{} 2,3<< {word:A}", graph, "E", "F", "G", "I");
377+
runTest("{} 2,3<< {word:A}", graph, "E", "F", "G", "J");
371378

372379
runTest("{} 2,2<< {word:A}", graph, "E");
373380

@@ -378,33 +385,33 @@ public void testExactDepthRelations() {
378385
runTest("{} 0,10<< {word:A}", graph,
379386
"B", "C", "D", "E", "F", "G", "H", "I", "J");
380387

381-
runTest("{} 0,10>> {word:J}", graph,
382-
"A", "B", "C", "D", "E", "F", "G", "H", "I");
388+
runTest("{} 0,10>> {word:I}", graph,
389+
"A", "B", "C", "D", "E", "F", "G", "H", "J");
383390

384-
runTest("{} 2,3>> {word:J}", graph,
391+
runTest("{} 2,3>> {word:I}", graph,
385392
"B", "C", "D", "E", "F", "G", "H");
386393

387-
runTest("{} 2,2>> {word:J}", graph,
394+
runTest("{} 2,2>> {word:I}", graph,
388395
"E", "H");
389396

390397
// use this method to avoid the toString() test, since we expect it
391398
// to use 2,2>> instead of 2>>
392-
runTest(SemgrexPattern.compile("{} 2>> {word:J}"), graph,
399+
runTest(SemgrexPattern.compile("{} 2>> {word:I}"), graph,
393400
"E", "H");
394401

395-
runTest("{} 1,2>> {word:J}", graph,
396-
"E", "H", "I");
402+
runTest("{} 1,2>> {word:I}", graph,
403+
"E", "H", "J");
397404
}
398405

399406
/**
400407
* Tests that if there are different paths from A to I, those paths show up for exactly the right depths
401408
*/
402409
public void testMultipleDepths() {
403410
SemanticGraph graph = makeComplicatedGraph();
404-
runTest("{} 3,3<< {word:A}", graph, "F", "G", "I");
405-
runTest("{} 4,4<< {word:A}", graph, "H", "J");
406-
runTest("{} 5,5<< {word:A}", graph, "I");
407-
runTest("{} 6,6<< {word:A}", graph, "J");
411+
runTest("{} 3,3<< {word:A}", graph, "F", "G", "J");
412+
runTest("{} 4,4<< {word:A}", graph, "H", "I");
413+
runTest("{} 5,5<< {word:A}", graph, "J");
414+
runTest("{} 6,6<< {word:A}", graph, "I");
408415
}
409416

410417
public void testNamedNode() {

0 commit comments

Comments
 (0)