Search in sources :

Example 6 with TokenBuilder

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;
}
Also used : TokenBuilder(org.apache.uima.fit.testing.factory.TokenBuilder) JCas(org.apache.uima.jcas.JCas) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)

Example 7 with TokenBuilder

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;
}
Also used : TokenBuilder(org.apache.uima.fit.testing.factory.TokenBuilder) TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) JCas(org.apache.uima.jcas.JCas) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token) Sentence(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)

Aggregations

Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)7 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)7 TokenBuilder (org.apache.uima.fit.testing.factory.TokenBuilder)7 JCas (org.apache.uima.jcas.JCas)7 TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)3 Test (org.junit.Test)2 AgreementResult (de.tudarmstadt.ukp.clarin.webanno.curation.agreement.AgreementUtils.AgreementResult)1 ArcDiffAdapter (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ArcDiffAdapter)1 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)1 NamedEntity (de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 AnalysisEngine (org.apache.uima.analysis_engine.AnalysisEngine)1 AnalysisEngineDescription (org.apache.uima.analysis_engine.AnalysisEngineDescription)1 CAS (org.apache.uima.cas.CAS)1 Type (org.apache.uima.cas.Type)1 AnnotationFS (org.apache.uima.cas.text.AnnotationFS)1 ExternalResourceDescription (org.apache.uima.resource.ExternalResourceDescription)1