Search in sources :

Example 6 with CollectionException

use of org.apache.uima.collection.CollectionException in project dkpro-tc by dkpro.

the class MultiLabelOutcomeAnnotator method process.

@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
    try {
        for (String outcomeValue : getTextClassificationOutcomes(jcas)) {
            TextClassificationOutcome outcome = new TextClassificationOutcome(jcas);
            outcome.setOutcome(outcomeValue);
            outcome.addToIndexes();
        }
    } catch (CollectionException e) {
        throw new AnalysisEngineProcessException(e);
    }
}
Also used : TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome) CollectionException(org.apache.uima.collection.CollectionException) AnalysisEngineProcessException(org.apache.uima.analysis_engine.AnalysisEngineProcessException)

Example 7 with CollectionException

use of org.apache.uima.collection.CollectionException in project dkpro-tc by dkpro.

the class TestReaderSingleLabelUnitReader method getNext.

@Override
public void getNext(CAS aCAS) throws IOException, CollectionException {
    super.getNext(aCAS);
    JCas jcas;
    try {
        jcas = aCAS.getJCas();
        JCasId id = new JCasId(jcas);
        id.setId(jcasId++);
        id.addToIndexes();
    } catch (CASException e) {
        throw new CollectionException();
    }
    String documentText = aCAS.getDocumentText();
    int s = 0;
    for (String t : documentText.split(" ")) {
        int e = documentText.indexOf(t, s) + t.length();
        new TextClassificationTarget(jcas, s, e).addToIndexes();
        new TextClassificationOutcome(jcas, s, e).addToIndexes();
        s += 1;
    }
}
Also used : JCasId(org.dkpro.tc.api.type.JCasId) CollectionException(org.apache.uima.collection.CollectionException) TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome) TextClassificationTarget(org.dkpro.tc.api.type.TextClassificationTarget) JCas(org.apache.uima.jcas.JCas) CASException(org.apache.uima.cas.CASException)

Example 8 with CollectionException

use of org.apache.uima.collection.CollectionException in project dkpro-tc by dkpro.

the class PairReader_ImplBase method getNext.

@Override
public void getNext(JCas jcas) throws IOException, CollectionException {
    try {
        createMetaData(jcas, getCollectionId1() + "_" + getCollectionId2(), getDocumentId1() + "_" + getDocumentId2(), getTitle1() + " " + getTitle2());
        createView(PART_ONE, jcas, getLanguage1(), getText1(), getDocumentId1(), getTitle1());
        createView(PART_TWO, jcas, getLanguage2(), getText2(), getDocumentId2(), getTitle2());
    } catch (TextClassificationException e) {
        throw new CollectionException(e);
    } catch (CASException e) {
        throw new CollectionException(e);
    }
}
Also used : TextClassificationException(org.dkpro.tc.api.exception.TextClassificationException) CollectionException(org.apache.uima.collection.CollectionException) CASException(org.apache.uima.cas.CASException)

Example 9 with CollectionException

use of org.apache.uima.collection.CollectionException in project dkpro-tc by dkpro.

the class TestReaderSingleLabel method getNext.

@Override
public void getNext(CAS aCAS) throws IOException, CollectionException {
    super.getNext(aCAS);
    JCas jcas;
    try {
        jcas = aCAS.getJCas();
        JCasId id = new JCasId(jcas);
        id.setId(jcasId);
        id.addToIndexes();
    } catch (CASException e) {
        throw new CollectionException();
    }
    TextClassificationOutcome outcome = new TextClassificationOutcome(jcas);
    outcome.setOutcome(getTextClassificationOutcome(jcas));
    outcome.addToIndexes();
}
Also used : JCasId(org.dkpro.tc.api.type.JCasId) CollectionException(org.apache.uima.collection.CollectionException) TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome) JCas(org.apache.uima.jcas.JCas) CASException(org.apache.uima.cas.CASException)

Example 10 with CollectionException

use of org.apache.uima.collection.CollectionException in project dkpro-tc by dkpro.

the class TestReaderMultiLabel method getNext.

@Override
public void getNext(CAS aCAS) throws IOException, CollectionException {
    super.getNext(aCAS);
    JCas jcas;
    try {
        jcas = aCAS.getJCas();
        JCasId id = new JCasId(jcas);
        id.setId(jcasId);
        id.addToIndexes();
    } catch (CASException e) {
        throw new CollectionException();
    }
    for (String outcomeValue : getTextClassificationOutcomes(jcas)) {
        TextClassificationOutcome outcome = new TextClassificationOutcome(jcas);
        outcome.setOutcome(outcomeValue);
        outcome.addToIndexes();
    }
}
Also used : JCasId(org.dkpro.tc.api.type.JCasId) CollectionException(org.apache.uima.collection.CollectionException) TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome) JCas(org.apache.uima.jcas.JCas) CASException(org.apache.uima.cas.CASException)

Aggregations

CollectionException (org.apache.uima.collection.CollectionException)15 CASException (org.apache.uima.cas.CASException)10 JCas (org.apache.uima.jcas.JCas)9 TextClassificationOutcome (org.dkpro.tc.api.type.TextClassificationOutcome)9 JCasId (org.dkpro.tc.api.type.JCasId)5 TextClassificationTarget (org.dkpro.tc.api.type.TextClassificationTarget)4 DocumentMetaData (de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 ResourceInitializationException (org.apache.uima.resource.ResourceInitializationException)2 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)1 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)1 WLFormatException (eu.clarin.weblicht.wlfxb.io.WLFormatException)1 TextCorpus (eu.clarin.weblicht.wlfxb.tc.api.TextCorpus)1 WLData (eu.clarin.weblicht.wlfxb.xb.WLData)1 BufferedInputStream (java.io.BufferedInputStream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 AnalysisEngineProcessException (org.apache.uima.analysis_engine.AnalysisEngineProcessException)1 TextClassificationException (org.dkpro.tc.api.exception.TextClassificationException)1