use of org.apache.uima.fit.testing.factory.TokenBuilder in project webanno by webanno.
the class WebAnnoTsv3WriterTestBase method makeJCasOneSentence.
private static JCas makeJCasOneSentence() throws UIMAException {
JCas jcas = makeJCas();
TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class, Sentence.class);
tb.buildTokens(jcas, "This is a test .");
return jcas;
}
use of org.apache.uima.fit.testing.factory.TokenBuilder in project webanno by webanno.
the class Tsv3XSerializerTest method makeJCasOneSentence.
private JCas makeJCasOneSentence(String aText) throws UIMAException {
TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
TypeSystemDescription local = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath("src/test/resources/desc/type/webannoTestTypes.xml");
TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
JCas jcas = JCasFactory.createJCas(merged);
DocumentMetaData.create(jcas).setDocumentId("doc");
TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class, Sentence.class);
tb.buildTokens(jcas, aText);
// sentence break
for (Sentence s : select(jcas, Sentence.class)) {
s.removeFromIndexes();
}
// Add a new sentence covering the whole text
new Sentence(jcas, 0, jcas.getDocumentText().length()).addToIndexes();
return jcas;
}
Aggregations