DTAFileReader extends CollectionReader_ImplBase { @Override public boolean hasNext() throws IOException, CollectionException { return counter < inputFiles.size(); }  @Override void close(); @Override void getNext(final CAS aCAS); @Override Progress[] getProgress(); @Override boolean hasNext(); @Override void initialize(); static final String PARAM_INPUTFILE; static final String PARAM_NORMALIZE; static final String PARAM_FORMAT_2017; }
@Test public void testHeader() throws Exception { for (Version version : Version.values()) { final JCas jcas = process(true, version); final FSIterator<Annotation> i = jcas .getAnnotationIndex(Header.type).iterator(); final Set<Header> header = new HashSet<>(); while (i.hasNext()) header.add((Header) i.next()); assertEquals(1, header.size()); final Header h = header.iterator().next(); assertEquals("Des Knaben Wunderhorn", h.getTitle()); assertEquals("Alte deutsche Lieder", h.getSubtitle()); assertEquals("1", h.getVolume()); assertEquals(2, h.getAuthors().size()); assertEquals(version == Version.v2017 ? 8 : 6, h.getEditors().size()); final PersonInfo arnim = (PersonInfo) h.getAuthors().get(0); assertEquals("Arnim", arnim.getSurename()); assertEquals("Achim von", arnim.getForename()); assertEquals("http: final FSArray classes = h.getClassifications(); assertEquals(version == Version.v2017 ? 2 : 3, classes.size()); assertTrue(containsClassification(classes, DTABelletristik.class)); assertTrue( containsClassification(classes, DWDS1Belletristik.class)); if (version == Version.v2017) assertFalse(containsClassification(classes, DWDS2Wissenschaft.class)); else assertTrue(containsClassification(classes, DWDS2Wissenschaft.class)); assertTrue(h.getIsCoreCorpus()); assertEquals("1806", h.getYear()); assertEquals("Heidelberg", h.getPublicationPlaces(0)); assertEquals("Frankfurt", h.getPublicationPlaces(1)); assertEquals("Mohr u: Zimmer", h.getPublishers().get(0)); } }
@Test public void testLemmata() { final String expected = "d Knabe Wunderhorn . alt deutsch Lied sammeln von L. A. v. Arnim und " + "Clemens Brentano . d Knabe Wunderhorn alt deutsch Lied L. Achim v. Arnim . " + "clemens brentano . Heidelberg , bei Mohr u. Zimmer ."; for (Version version : Version.values()) { StringBuilder actual = new StringBuilder(); try { final JCas jcas = process(true, version); final FSIterator<Annotation> iter = jcas .getAnnotationIndex(Lemma.type).iterator(); while (iter.hasNext()) actual.append(((Lemma) iter.next()).getValue()).append(" "); assertEquals(expected, actual.substring(0, actual.length() - 1)); } catch (final Exception e) { e.printStackTrace(); fail(); } } }
@Test public void testPOS() { final String expected = "ART NN NN $. ADJA ADJA NN VVPP APPR NE NE APPR NE KON NE NE $. " + "ART NN NN ADJA ADJA NN NE NE APPRART NE $. FM.la FM.la $. NE $, APPR NN APPR NN $."; for (Version version : Version.values()) { StringBuilder actual = new StringBuilder(); try { final JCas jcas = process(true, version); final FSIterator<Annotation> iter = jcas .getAnnotationIndex(STTSPOSTag.type).iterator(); while (iter.hasNext()) actual.append(((STTSPOSTag) iter.next()).getValue()) .append(" "); assertEquals(expected, actual.substring(0, actual.length() - 1)); } catch (final Exception e) { e.printStackTrace(); System.out.println(version); fail(); } } }
@Test public void testSentences() { final List<String> expected = Arrays.asList(new String[] { "Des Knaben Wunderhorn.", "Alte deutsche Lieder gesammelt von L. A. v. Arnim und Clemens Brentano.", "Des Knaben Wunderhorn Alte deutsche Lieder L. Achim v. Arnim.", "Clemens Brentano.", "Heidelberg, bei Mohr u. Zimmer." }); for (Version version : Version.values()) { List<String> actual = new ArrayList<>(); try { final JCas jcas = process(true, version); final FSIterator<Annotation> iter = jcas .getAnnotationIndex(Sentence.type).iterator(); while (iter.hasNext()) actual.add(iter.next().getCoveredText()); assertEquals(expected, actual); } catch (final Exception e) { e.printStackTrace(); fail(); } } }