Repository navigation
Expand file tree
/
Copy pathtest_annotation.py
More file actions
616 lines (511 loc) · 24.2 KB
/
Copy pathtest_annotation.py
File metadata and controls
616 lines (511 loc) · 24.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
"""
Runs the same tests over the annotation sets as provided in GATE java.
This will actually use GATE to load the documents for now because we don't support
parsing the XML files directly.
"""
from gate import *
import unittest, sys, os
"""Tests for the Annotation classes"""
Gate = gate.Gate() # Use this for loading documents
class TestAnnotationSet(unittest.TestCase):
def setUp(self):
self.document = Gate.load("data/doc0.html")
self.basicAS = self.document.annotationSets[None]
self.basicAS.add(10, 20, "T1", {})
self.basicAS.add(10, 20, "T2", {})
self.basicAS.add(10, 20, "T3", {})
self.basicAS.add(10, 20, "T1", {})
fm = {"pos": "NN",
"author": "hamish",
"version": 1}
self.basicAS.add(10, 20, "T1", fm)
self.basicAS.add(15, 40, "T1", fm)
self.basicAS.add(15, 40, "T3", fm)
self.basicAS.add(15, 40, "T1", fm)
fm = {
"pos": "JJ",
"author": "the devil himself",
"version": 44,
"created": "monday"
}
self.basicAS.add(15, 40, "T3", fm)
self.basicAS.add(15, 40, "T1", fm)
self.basicAS.add(15, 40, "T1", fm)
def testOffsetIndex(self):
"""Test indexing by offset"""
localAS = AnnotationSet(self.document)
newId = localAS.add(10, 20, "T", {}).id
self.assertEquals(newId, 1)
a = localAS.byID(newId)
self.assertEquals(a.start, 10)
self.assertEquals(a.end, 20)
newId = localAS.add(10, 30, "T", {}).id
self.assertEquals(newId, 2)
a = localAS.byID(newId)
self.assertEquals(a.start, 10)
self.assertEquals(a.end, 30)
self.assertEquals(len(localAS.at(10)), 2)
# Immutability tests have been dropped because I don't think I need immutability
def testExceptions(self):
"""Test offset exception throwing"""
localAS = AnnotationSet(self.document)
with self.assertRaises(InvalidOffsetException):
localAS.add(-1, 1, "T", {})
with self.assertRaises(InvalidOffsetException):
localAS.add(1, -1, "T", {})
with self.assertRaises(InvalidOffsetException):
localAS.add(1, 0, "T", {})
with self.assertRaises(InvalidOffsetException):
localAS.add(None, 1, "T", {})
with self.assertRaises(InvalidOffsetException):
localAS.add(1, None, "T", {})
with self.assertRaises(InvalidOffsetException):
localAS.add(999999, 100000000, "T", {})
def testTypeIndex(self):
"""Test type index"""
doc = Gate.load("data/doc0.html")
localAS = AnnotationSet(doc)
localAS.add(10, 20, "T1", {}); # 0
localAS.add(10, 20, "T2", {}); # 1
localAS.add(10, 20, "T3", {}); # 2
localAS.add(10, 20, "T1", {}); # 3
localAS.add(10, 20, "T1", {}); # 4
localAS.add(10, 20, "T1", {}); # 5
# to trigger type indexing
localAS["T"]
localAS.add(10, 20, "T3", {}); # 6
localAS.add(10, 20, "T1", {}); # 7
localAS.add(10, 20, "T3", {}); # 8
localAS.add(10, 20, "T1", {}); # 9
localAS.add(10, 20, "T1", {}); # 10
self.assertEquals(0, localAS["T"].size())
self.assertEquals(7, localAS["T1"].size())
self.assertEquals(1, localAS["T2"].size())
self.assertEquals(3, localAS["T3"].size())
# let's check that we've only got two nodes, what the ids are and so on
for idCounter, a in enumerate(localAS):
# check annot ids
self.assertEquals(idCounter+1, a.id)
# start offset
self.assertEquals(10, a.start)
# end offset
self.assertEquals(20, a.end)
def testGetCovering(self):
self.assertEquals(0, self.basicAS[None].covering(0,5).size())
self.assertEquals(0, self.basicAS["T1"].covering(0,5).size())
#None and blank strings should be treated the same. Just test
#with both a couple of times. Mostly can just test with None.
self.assertEquals(0, self.basicAS[None].covering(9,12).size())
# self.assertEquals(0, self.basicAS[" "].covering(9,12).size()) # REMOVED: I don't think this is a good idea
self.assertEquals(0, self.basicAS["T1"].covering(9,12).size())
self.assertEquals(5, self.basicAS[None].covering(10,20).size())
# self.assertEquals(5, self.basicAS[" "].covering(10,20).size())
self.assertEquals(3, self.basicAS["T1"].covering(10,20).size())
self.assertEquals(11, self.basicAS[None].covering(16,20).size())
self.assertEquals(7, self.basicAS["T1"].covering(16,20).size())
self.assertEquals(6, self.basicAS[None].covering(16,21).size())
self.assertEquals(4, self.basicAS["T1"].covering(16,21).size())
def testRemove(self):
result = self.basicAS["T1"]
self.assertEquals(7, result.size())
result = self.basicAS.firstAfter(9)
self.assertEquals(5, result.size())
annotation = self.basicAS.byID(1)
self.basicAS.remove(annotation) # REmove annotation with index 1
self.assertEquals(10, self.basicAS.size())
self.assertEquals(10, len(self.basicAS._annots))
result = self.basicAS.type("T1")
self.assertEquals(6, result.size())
result = self.basicAS.firstAfter(9)
self.assertEquals(4, result.size())
with self.assertRaises(KeyError):
self.basicAS.byID(1)
self.basicAS.remove(self.basicAS.byID(8))
self.assertEquals(9, self.basicAS.size())
for annotation in self.basicAS.type(None): # Type is called to create a clone in case iteration is unsafe.
self.basicAS.remove(annotation)
self.assertEquals(0, self.basicAS.size())
self.assertEquals(0, self.basicAS.type("T1").size())
with self.assertRaises(KeyError):
self.basicAS.byID(2)
def testRemoveInexistant(self):
self.basicAS.add(0, 10, "Foo", {})
ann = self.basicAS.type("Foo").first()
self.basicAS.remove(ann)
with self.assertRaises(KeyError): # GATE allows this, but it doesn't seem like a good idea...
self.basicAS.remove(ann)
# Iterator removal tests were removed because removing from an iterator is not very pythonic.
# def testGap(self):
# """Test get with offset and no annotation starting at given offset"""
# localAS = self.basicAS
# localAS.clear()
# FeatureMap fm = Factory.newFeatureMap()
# fm.put("A", "B")
# localAS.add(0, 10, "foo", fm)
# localAS.add(11, 20, "foo", fm)
# localAS.add(10, 11, "space", fm)
# #do the input selection (ignore spaces)
# input = {"foo", "foofoo")
# AnnotationSet annotations = null
# if(input.isEmpty()) annotations = localAS
# else{
# Iterator<String> typesIter = input.iterator()
# AnnotationSet ofOneType = null
# while(typesIter.hasNext()){
# ofOneType = localAS.get(typesIter.next())
# if(ofOneType != null){
# #System.out.println("Adding " + ofOneType.getAllTypes())
# if(annotations == null) annotations = ofOneType
# else annotations.addAll(ofOneType)
# }
# }
# }
# # if(annotations == null) annotations = AnnotationSetImpl(doc)
# if (DEBUG)
# Out.println(
# "Actual input:" + annotations.getAllTypes() + "\n" + annotations
# )
# AnnotationSet res =
# annotations.get("foo", Factory.newFeatureMap(), 10)
# if (DEBUG)
# Out.println(res)
# assertTrue(!res.isEmpty())
# }
# """Test Overlaps"""
# public void testOverlapsAndCoextensive() throws InvalidOffsetException {
# Node node1 = NodeImpl(new Integer(1),10)
# Node node2 = NodeImpl(new Integer(2),20)
# Node node4 = NodeImpl(new Integer(4),15)
# Node node5 = NodeImpl(new Integer(5),20)
# Node node6 = NodeImpl(new Integer(6),30)
# FeatureMap fm1 = SimpleFeatureMapImpl()
# fm1.put("color","red")
# fm1.put("Age",25)
# fm1.put(23, "Cristian")
# FeatureMap fm2 = SimpleFeatureMapImpl()
# fm2.put("color","red")
# fm2.put("Age",25)
# fm2.put(23, "Cristian")
# FeatureMap fm4 = SimpleFeatureMapImpl()
# fm4.put("color","red")
# fm4.put("Age",26)
# fm4.put(23, "Cristian")
# FeatureMap fm3 = SimpleFeatureMapImpl()
# fm3.put("color","red")
# fm3.put("Age",25)
# fm3.put(23, "Cristian")
# fm3.put("best",new Boolean(true))
# # Start=10, End = 20
# Annotation annot1 = createAnnotation(new Integer(1),
# node1,
# node2,
# "pos",
# null)
# # Start=20, End = 30
# Annotation annot2 = createAnnotation (new Integer(2),
# node2,
# node6,
# "pos",
# null)
# # Start=20, End = 30
# Annotation annot3 = createAnnotation (new Integer(3),
# node5,
# node6,
# "pos",
# null)
# # Start=20, End = 20
# Annotation annot4 = createAnnotation (new Integer(4),
# node2,
# node5,
# "pos",
# null)
# # Start=10, End = 30
# Annotation annot5 = createAnnotation (new Integer(5),
# node1,
# node6,
# "pos",
# null)
# # Start=10, End = 15
# Annotation annot6 = createAnnotation (new Integer(6),
# node1,
# node4,
# "pos",
# null)
# # Start=null, End = null
# Annotation annot7 = createAnnotation (new Integer(7),
# null,
# null,
# "pos",
# null)
# # MAP
# # annot1 -> Start=10, End = 20
# # annot2 -> Start=20, End = 30
# # annot3 -> Start=20, End = 30
# # annot4 -> Start=20, End = 20
# # annot5 -> Start=10, End = 30
# # annot6 -> Start=10, End = 15
# # Not overlaping situations
# assertTrue("Those annotations does not overlap!",!annot1.overlaps(annot3))
# assertTrue("Those annotations does not overlap!",!annot1.overlaps(annot2))
# assertTrue("Those annotations does not overlap!",!annot2.overlaps(annot1))
# assertTrue("Those annotations does not overlap!",!annot3.overlaps(annot1))
# assertTrue("Those annotations does not overlap!",!annot4.overlaps(annot6))
# assertTrue("Those annotations does not overlap!",!annot6.overlaps(annot4))
# assertTrue("Those annotations does not overlap!",!annot6.overlaps(null))
# assertTrue("Those annotations does not overlap!",!annot1.overlaps(annot7))
# # Overlaping situations
# assertTrue("Those annotations does overlap!",annot4.overlaps(annot5))
# assertTrue("Those annotations does overlap!",annot5.overlaps(annot4))
# assertTrue("Those annotations does overlap!",annot1.overlaps(annot6))
# assertTrue("Those annotations does overlap!",annot6.overlaps(annot1))
# assertTrue("Those annotations does overlap!",annot2.overlaps(annot5))
# assertTrue("Those annotations does overlap!",annot5.overlaps(annot2))
# # Not coextensive situations
# assertTrue("Those annotations are not coextensive!",!annot1.coextensive(annot2))
# assertTrue("Those annotations are not coextensive!",!annot2.coextensive(annot1))
# assertTrue("Those annotations are not coextensive!",!annot4.coextensive(annot3))
# assertTrue("Those annotations are not coextensive!",!annot3.coextensive(annot4))
# assertTrue("Those annotations are not coextensive!",!annot4.coextensive(annot7))
# assertTrue("Those annotations are not coextensive!",!annot5.coextensive(annot6))
# assertTrue("Those annotations are not coextensive!",!annot6.coextensive(annot5))
# #Coextensive situations
# assertTrue("Those annotations are coextensive!",annot2.coextensive(annot2))
# assertTrue("Those annotations are coextensive!",annot2.coextensive(annot3))
# assertTrue("Those annotations are coextensive!",annot3.coextensive(annot2))
# }#testOverlapsAndCoextensive
# """Test Coextensive"""
# public void testIsPartiallyCompatibleAndCompatible()
# throws InvalidOffsetException {
# Node node1 = NodeImpl(new Integer(1),10)
# Node node2 = NodeImpl(new Integer(2),20)
# Node node4 = NodeImpl(new Integer(4),15)
# Node node5 = NodeImpl(new Integer(5),20)
# Node node6 = NodeImpl(new Integer(6),30)
# FeatureMap fm1 = SimpleFeatureMapImpl()
# fm1.put("color","red")
# fm1.put("Age",25)
# fm1.put(23, "Cristian")
# FeatureMap fm2 = SimpleFeatureMapImpl()
# fm2.put("color","red")
# fm2.put("Age",25)
# fm2.put(23, "Cristian")
# FeatureMap fm4 = SimpleFeatureMapImpl()
# fm4.put("color","red")
# fm4.put("Age",26)
# fm4.put(23, "Cristian")
# FeatureMap fm3 = SimpleFeatureMapImpl()
# fm3.put("color","red")
# fm3.put("Age",25)
# fm3.put(23, "Cristian")
# fm3.put("best",new Boolean(true))
# # Start=10, End = 20
# Annotation annot1 = createAnnotation(new Integer(1),
# node1,
# node2,
# "pos",
# fm1)
# # Start=20, End = 30
# Annotation annot2 = createAnnotation (new Integer(2),
# node2,
# node6,
# "pos",
# fm2)
# # Start=20, End = 30
# Annotation annot3 = createAnnotation (new Integer(3),
# node5,
# node6,
# "pos",
# fm3)
# # Start=20, End = 20
# Annotation annot4 = createAnnotation (new Integer(4),
# node2,
# node5,
# "pos",
# fm4)
# # Start=10, End = 30
# Annotation annot5 = createAnnotation (new Integer(5),
# node1,
# node6,
# "pos",
# fm3)
# # Start=10, End = 15
# Annotation annot6 = createAnnotation (new Integer(6),
# node1,
# node4,
# "pos",
# fm1)
# # MAP
# /*
# annot1 -> Start=10, End = 20,{color="red",Age="25",23="Cristian"}
# annot2 -> Start=20, End = 30,{color="red",Age="25",23="Cristian"}
# annot3 -> Start=20, End = 30,{color="red",Age="25",23="Cristian",best="true"}
# annot4 -> Start=20, End = 20,{color="red",Age="26",23="Cristian"}
# annot5 -> Start=10, End = 30,{color="red",Age="25",23="Cristian",best="true"}
# annot6 -> Start=10, End = 15,{color="red",Age="25",23="Cristian"}
# */
# # Not compatible situations
# assertTrue("Those annotations are not compatible!",!annot3.isCompatible(annot2))
# # Not partially compatible situations
# # They don't overlap
# assertTrue("Those annotations("+ annot1 +" & " +
# annot2+ ") are not partially compatible!",
# !annot1.isPartiallyCompatible(annot2))
# # Again they don't overlap
# assertTrue("Those annotations("+ annot1 +" & " +
# annot3+ ") are not partially compatible!",
# !annot1.isPartiallyCompatible(annot3))
# # Fails because of the age value
# assertTrue("Those annotations("+ annot1 +" & " +
# annot4+ ") are not partially compatible!",
# !annot1.isPartiallyCompatible(annot4))
# # Fails because of the value of Age
# assertTrue("Those annotations("+ annot4 +" & " +
# annot5+ ") are not partially compatible!",
# !annot4.isPartiallyCompatible(annot5))
# # Features from annot6 does not subsumes features annot3
# assertTrue("Those annotations("+ annot3 +" & " +
# annot6+ ") are not partially compatible!",
# !annot3.isPartiallyCompatible(annot6,null))
# # Features from annot2 does not subsumes features annot5
# assertTrue("Those annotations("+ annot5 +" & " +
# annot2+ ") are not partially compatible!",
# !annot5.isPartiallyCompatible(annot2,null))
# Set<Object> keySet = HashSet<Object>()
# # They don't overlap
# assertTrue("Those annotations("+ annot2 +" & " +
# annot4+ ") are not partially compatible!",
# !annot2.isPartiallyCompatible(annot4,keySet))
# keySet.add("color")
# keySet.add("Age")
# keySet.add("best")
# # Fails because of best feture
# assertTrue("Those annotations("+ annot5 +" & " +
# annot2+ ") are not partially compatible!",
# !annot5.isPartiallyCompatible(annot2,keySet))
# # Fails because start=end in both cases and they don't overlap
# assertTrue("Those annotations("+ annot4 +" & " +
# annot4+ ") are not partially compatible!",
# !annot4.isPartiallyCompatible(annot4))
# /*
# annot1 -> Start=10, End = 20,{color="red",Age="25",23="Cristian"}
# annot2 -> Start=20, End = 30,{color="red",Age="25",23="Cristian"}
# annot3 -> Start=20, End = 30,{color="red",Age="25",23="Cristian",best="true"}
# annot4 -> Start=20, End = 20,{color="red",Age="26",23="Cristian"}
# annot5 -> Start=10, End = 30,{color="red",Age="25",23="Cristian",best="true"}
# annot6 -> Start=10, End = 15,{color="red",Age="25",23="Cristian"}
# */
# # Compatible situations
# assertTrue("Those annotations("+ annot2 +" & " +
# annot3+ ") should be compatible!",
# annot2.isCompatible(annot3))
# assertTrue("Those annotations("+ annot2 +" & " +
# annot3+ ") should be compatible!",
# annot2.isCompatible(annot3,null))
# assertTrue("Those annotations("+ annot2 +" & " +
# annot3+ ") should be compatible!",
# annot2.isCompatible(annot3,new HashSet<String>()))
# assertTrue("Those annotations("+ annot4 +" & " +
# annot4+ ") should be compatible!",
# annot4.isCompatible(annot4))
# keySet = HashSet<Object>()
# keySet.add("color")
# keySet.add(23)
# assertTrue("Those annotations("+ annot3 +" & " +
# annot2+ ") should be compatible!",
# annot3.isCompatible(annot2,keySet))
# # Partially compatible situations
# assertTrue("Those annotations("+ annot2 +" & " +
# annot3+ ") should be partially compatible!",
# annot2.isPartiallyCompatible(annot3))
# assertTrue("Those annotations("+ annot2 +" & " +
# annot2+ ") should be partially compatible!",
# annot2.isPartiallyCompatible(annot2))
# assertTrue("Those annotations are partially compatible!",
# annot1.isPartiallyCompatible(annot5))
# assertTrue("Those annotations are partially compatible!",
# annot1.isPartiallyCompatible(annot6))
# assertTrue("Those annotations are partially compatible!",
# annot3.isPartiallyCompatible(annot5))
# assertTrue("Those annotations are partially compatible!",
# annot5.isPartiallyCompatible(annot3))
# assertTrue("Those annotations are partially compatible!",
# annot6.isPartiallyCompatible(annot5))
# }# testIsPartiallyCompatibleAndCompatible
# public void testFeatureSubsumeMethods(){
# FeatureMap fm1 = Factory.newFeatureMap()
# fm1.put("k1","v1")
# fm1.put("k2","v2")
# FeatureMap fm2 = Factory.newFeatureMap()
# fm2.put("k1","v1")
# Set<String> featKeysSet1 = HashSet<String>()
# featKeysSet1.add("k1")
# featKeysSet1.add("k2")
# featKeysSet1.add("k3")
# featKeysSet1.add("k4")
# assertTrue(fm1 + " should subsume " + fm2 + " using the key set" +
# featKeysSet1,fm1.subsumes(fm2, featKeysSet1))
# assertTrue(fm1 + " should subsume " + fm2 +
# " taking all feat into consideration",
# fm1.subsumes(fm2, null))
# FeatureMap fm3 = Factory.newFeatureMap()
# fm3.put("k1","v1")
# fm3.put("k2","v2")
# fm3.put("k3",new Integer(3))
# Set<String> featKeysSet2 = HashSet<String>()
# featKeysSet2.add("k1")
# assertTrue(fm1 + " should subsume " + fm3 + " using the key set" +
# featKeysSet2,fm1.subsumes(fm3, featKeysSet2))
# assertTrue(fm1 + " should NOT subsume " + fm3 +
# " taking all feats into consideration",
# !fm1.subsumes(fm3,null))
# FeatureMap fm4 = Factory.newFeatureMap()
# fm4.put("k1",new Integer(2))
# fm4.put("k2","v2")
# fm4.put("k3","v3")
# Set<String> featKeysSet3 = HashSet<String>()
# featKeysSet3.add("k2")
# assertTrue(fm3 + " should subsume " + fm4 + " using the key set" +
# featKeysSet3, fm4.subsumes(fm3,featKeysSet3))
# assertTrue(fm4 + " should NOT subsume " + fm3 +
# " taking all feats into consideration",
# !fm4.subsumes(fm3,null))
# }# testFeatureSubsumeMethods()
# protected Annotation createAnnotation
# (Integer id, Node start, Node end, String type, FeatureMap features) {
# return new AnnotationImpl(id, start, end, type, features)
# }
# """Test inDocumentOrder() and getStartingAt(long)"""
# public void testDocumentOrder() throws Exception {
# FeatureMap params = Factory.newFeatureMap()
# params.put(Document.DOCUMENT_URL_PARAMETER_NAME, new URL(TestDocument.getTestServerName()+"tests/doc0.html"))
# params.put(Document.DOCUMENT_MARKUP_AWARE_PARAMETER_NAME, "true")
# Document doc = (Document)Factory.createResource("gate.corpora.DocumentImpl",
# params)
# AnnotationSet originals = doc.getAnnotations("Original markups")
# if(originals instanceof AnnotationSetImpl) {
# AnnotationSetImpl origimpl = (AnnotationSetImpl)originals
# List<Annotation> ordered = origimpl.inDocumentOrder()
# assertNotNull(ordered)
# assertEquals(20, ordered.size())
# assertEquals(33, ordered.get(4).getStartNode().getOffset().intValue())
# for(int i=1;i<ordered.size();i++) {
# assertTrue("Elements "+(i-1)+"/"+i,
# ordered.get(i-1).getStartNode().getOffset() <= ordered.get(i).getStartNode().getOffset())
# }
# AnnotationSet anns
# anns = origimpl.getStartingAt(0)
# assertEquals(4,anns.size())
# anns = origimpl.getStartingAt(1)
# assertEquals(0,anns.size())
# anns = origimpl.getStartingAt(33)
# assertEquals(4,anns.size())
# anns = origimpl.getStartingAt(48)
# assertEquals(1,anns.size())
# anns = origimpl.getStartingAt(251)
# assertEquals(1,anns.size())
# }
# } # testDocumentOrder()
if __name__ == '__main__':
Gate.start()
unittest.main()
Gate.stop()