@@ -227,6 +227,13 @@ public void testReferencedRegex() {
227
227
// TODO: implement referencing regexes
228
228
}
229
229
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
+ */
230
237
public static SemanticGraph makeComplicatedGraph () {
231
238
SemanticGraph graph = new SemanticGraph ();
232
239
String [] words = {"A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" };
@@ -256,15 +263,15 @@ public static SemanticGraph makeComplicatedGraph() {
256
263
UniversalEnglishGrammaticalRelations .ADJECTIVAL_MODIFIER , 1.0 , false );
257
264
graph .addEdge (nodes [4 ], nodes [6 ],
258
265
UniversalEnglishGrammaticalRelations .ADVERBIAL_MODIFIER , 1.0 , false );
259
- graph .addEdge (nodes [4 ], nodes [8 ],
266
+ graph .addEdge (nodes [4 ], nodes [9 ],
260
267
UniversalEnglishGrammaticalRelations .MODIFIER , 1.0 , false );
261
268
graph .addEdge (nodes [5 ], nodes [7 ],
262
269
UniversalEnglishGrammaticalRelations .POSSESSION_MODIFIER , 1.0 , false );
263
270
graph .addEdge (nodes [6 ], nodes [7 ],
264
271
UniversalEnglishGrammaticalRelations .CASE_MARKER , 1.0 , false );
265
- graph .addEdge (nodes [7 ], nodes [8 ],
272
+ graph .addEdge (nodes [7 ], nodes [9 ],
266
273
UniversalEnglishGrammaticalRelations .AGENT , 1.0 , false );
267
- graph .addEdge (nodes [8 ], nodes [9 ],
274
+ graph .addEdge (nodes [9 ], nodes [8 ],
268
275
UniversalEnglishGrammaticalRelations .DETERMINER , 1.0 , false );
269
276
270
277
return graph ;
@@ -284,14 +291,14 @@ public void testComplicatedGraph() {
284
291
runTest ("{} > {word:E}" , graph ,
285
292
"B" , "C" , "D" );
286
293
287
- runTest ("{} > {word:J }" , graph ,
288
- "I " );
294
+ runTest ("{} > {word:I }" , graph ,
295
+ "J " );
289
296
290
297
runTest ("{} < {word:E}" , graph ,
291
- "F" , "G" , "I " );
298
+ "F" , "G" , "J " );
292
299
293
- runTest ("{} < {word:I }" , graph ,
294
- "J " );
300
+ runTest ("{} < {word:J }" , graph ,
301
+ "I " );
295
302
296
303
runTest ("{} << {word:A}" , graph ,
297
304
"B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" );
@@ -317,10 +324,10 @@ public void testComplicatedGraph() {
317
324
runTest ("{} << {word:H}" , graph ,
318
325
"I" , "J" );
319
326
320
- runTest ("{} << {word:I }" , graph ,
321
- "J " );
327
+ runTest ("{} << {word:J }" , graph ,
328
+ "I " );
322
329
323
- runTest ("{} << {word:J }" , graph );
330
+ runTest ("{} << {word:I }" , graph );
324
331
325
332
runTest ("{} << {word:K}" , graph );
326
333
@@ -344,11 +351,11 @@ public void testComplicatedGraph() {
344
351
runTest ("{} >> {word:H}" , graph ,
345
352
"A" , "B" , "C" , "D" , "E" , "F" , "G" );
346
353
347
- runTest ("{} >> {word:I }" , graph ,
354
+ runTest ("{} >> {word:J }" , graph ,
348
355
"A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" );
349
356
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 " );
352
359
353
360
runTest ("{} >> {word:K}" , graph );
354
361
}
@@ -359,15 +366,15 @@ public void testRelationType() {
359
366
"B" , "E" , "F" , "G" , "H" , "I" , "I" , "J" , "J" );
360
367
361
368
runTest ("{} >>det {}" , graph ,
362
- "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I " );
369
+ "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "J " );
363
370
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 " );
366
373
}
367
374
368
375
public void testExactDepthRelations () {
369
376
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 " );
371
378
372
379
runTest ("{} 2,2<< {word:A}" , graph , "E" );
373
380
@@ -378,33 +385,33 @@ public void testExactDepthRelations() {
378
385
runTest ("{} 0,10<< {word:A}" , graph ,
379
386
"B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" );
380
387
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 " );
383
390
384
- runTest ("{} 2,3>> {word:J }" , graph ,
391
+ runTest ("{} 2,3>> {word:I }" , graph ,
385
392
"B" , "C" , "D" , "E" , "F" , "G" , "H" );
386
393
387
- runTest ("{} 2,2>> {word:J }" , graph ,
394
+ runTest ("{} 2,2>> {word:I }" , graph ,
388
395
"E" , "H" );
389
396
390
397
// use this method to avoid the toString() test, since we expect it
391
398
// to use 2,2>> instead of 2>>
392
- runTest (SemgrexPattern .compile ("{} 2>> {word:J }" ), graph ,
399
+ runTest (SemgrexPattern .compile ("{} 2>> {word:I }" ), graph ,
393
400
"E" , "H" );
394
401
395
- runTest ("{} 1,2>> {word:J }" , graph ,
396
- "E" , "H" , "I " );
402
+ runTest ("{} 1,2>> {word:I }" , graph ,
403
+ "E" , "H" , "J " );
397
404
}
398
405
399
406
/**
400
407
* Tests that if there are different paths from A to I, those paths show up for exactly the right depths
401
408
*/
402
409
public void testMultipleDepths () {
403
410
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 " );
408
415
}
409
416
410
417
public void testNamedNode () {
0 commit comments