MCPcopy Create free account
hub / github.com/GateNLP/gate-core / testAnnotationSetHandling

Method testAnnotationSetHandling

src/test/java/gate/TestUtils.java:43–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41
42 // test getting and combining annotations
43 public void testAnnotationSetHandling()
44 throws InvalidOffsetException, ResourceInstantiationException {
45 // create a new document of 100 spaces
46 Document doc = Factory.newDocument(new String(new char[100]).replace("\0", " "));
47 // get an annotation set for the first couple of tests
48 AnnotationSet set1 = doc.getAnnotations("s1");
49 // add 3 coextensive annotations on top of each other
50 Annotation ann1_1 = set1.get(addAnn(set1,0,5,"t1.1",featureMap()));
51 Annotation ann1_2 = set1.get(addAnn(set1,0,5,"t1.2",featureMap()));
52 @SuppressWarnings("unused")
53 Annotation ann1_3 = set1.get(addAnn(set1,0,5,"t1.3",featureMap()));
54 // add 3 overlapping annotations
55 Annotation ann2_1 = set1.get(addAnn(set1,10,15,"t2.1",featureMap()));
56 @SuppressWarnings("unused")
57 Annotation ann2_2 = set1.get(addAnn(set1,11,16,"t2.2",featureMap()));
58 @SuppressWarnings("unused")
59 Annotation ann2_3 = set1.get(addAnn(set1,12,17,"t2.3",featureMap()));
60
61 AnnotationSet ret = getCoextensiveAnnotations(set1,ann1_1);
62 assertEquals(3, ret.size());
63
64 ret = minus(ret,ann1_1);
65 assertEquals(2, ret.size());
66
67 ret = minus(ret,ann2_1);
68 assertEquals(2, ret.size());
69
70 ret = minus(ret);
71 assertEquals(2, ret.size());
72
73 ret = minus(ret,ann1_2);
74 assertEquals(1, ret.size());
75
76 ret = getOverlappingAnnotations(set1, ann2_1);
77 assertEquals(3, ret.size());
78
79 ret = plus(ret,ann1_2);
80 assertEquals(4, ret.size());
81
82 ret = intersect(getCoextensiveAnnotations(set1,ann1_1),ret);
83 assertEquals(1, ret.size());
84
85 ret = getAnnotationsEndingAtOffset(set1, 15L);
86 assertEquals(1, ret.size());
87 assertEquals(15,ret.iterator().next().getEndNode().getOffset().longValue());
88
89 ret = getAnnotationsEndingAtOffset(set1, 5L);
90 assertEquals(3, ret.size());
91
92 } // testAnnotationSetHandling
93} // class TestAnnotation
94

Callers

nothing calls this directly

Calls 15

newDocumentMethod · 0.95
getMethod · 0.95
addAnnMethod · 0.80
featureMapMethod · 0.80
minusMethod · 0.80
plusMethod · 0.80
intersectMethod · 0.80
getAnnotationsMethod · 0.65
sizeMethod · 0.65

Tested by

no test coverage detected