CAS cas = CasCreationUtils.createCas(tsDesc, null, new FsIndexDescription[0]);
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
XCASDeserializer xcasDeserializer = new XCASDeserializer(cas.getTypeSystem());
File xcasFile = new File(xcasDir, sampleXcas1FileName);
parser.parse(xcasFile, xcasDeserializer.getXCASHandler(cas));
AnnotationTreeNode root = cas.getAnnotationIndex().tree(cas.getDocumentAnnotation())
.getRoot();
// There are 7 paragraph annotations in the CAS.
assertTrue("There should be 7 paragraphs, but are: " + root.getChildCount(), root
.getChildCount() == 7);
// The first paragraph contains 19 sentences, each subsequent one
// contains only one sentence.
assertTrue(root.getChild(0).getChildCount() == 19);
for (int i = 1; i < root.getChildCount(); i++) {
assertTrue(root.getChild(i).getChildCount() == 1);
}
// First sentence contains 8 tokens.
assertTrue(root.getChild(0).getChild(0).getChildCount() == 8);
// Same for only sentence in second paragraph.
assertTrue(root.getChild(1).getChild(0).getChildCount() == 8);
} catch (IOException e) {
e.printStackTrace();
assertTrue(false);
}
}