Search in sources :

Example 11 with CollectionException

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

the class SingleLabelReaderBase method getNext.

@Override
public void getNext(CAS aCAS) throws IOException, CollectionException {
    super.getNext(aCAS);
    JCas jcas;
    try {
        jcas = aCAS.getJCas();
    } catch (CASException e) {
        throw new CollectionException();
    }
    TextClassificationOutcome outcome = new TextClassificationOutcome(jcas);
    outcome.setOutcome(getTextClassificationOutcome(jcas));
    outcome.setWeight(getTextClassificationOutcomeWeight(jcas));
    outcome.addToIndexes();
    new TextClassificationTarget(jcas, 0, jcas.getDocumentText().length()).addToIndexes();
}
Also used : 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 12 with CollectionException

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

the class TestReaderRegression 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 13 with CollectionException

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

the class ReutersCorpusReader method getTextClassificationOutcomes.

@Override
public Set<String> getTextClassificationOutcomes(JCas jcas) throws CollectionException {
    Set<String> outcomes = new HashSet<String>();
    DocumentMetaData dmd = DocumentMetaData.get(jcas);
    String titleWithoutExtension = FilenameUtils.removeExtension(dmd.getDocumentTitle());
    if (!goldLabelMap.containsKey(titleWithoutExtension)) {
        throw new CollectionException(new Throwable("No gold label for document: " + dmd.getDocumentTitle()));
    }
    for (String label : goldLabelMap.get(titleWithoutExtension)) {
        outcomes.add(label);
    }
    return outcomes;
}
Also used : CollectionException(org.apache.uima.collection.CollectionException) DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData) HashSet(java.util.HashSet)

Example 14 with CollectionException

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

the class MultiLabelOutcomeAnnotator method getTextClassificationOutcomes.

public Set<String> getTextClassificationOutcomes(JCas jcas) throws CollectionException {
    Set<String> outcomes = new HashSet<String>();
    DocumentMetaData dmd = DocumentMetaData.get(jcas);
    String titleWithoutExtension = FilenameUtils.removeExtension(dmd.getDocumentTitle());
    if (!goldLabelMap.containsKey(titleWithoutExtension)) {
        throw new CollectionException(new Throwable("No gold label for document: " + dmd.getDocumentTitle()));
    }
    for (String label : goldLabelMap.get(titleWithoutExtension)) {
        outcomes.add(label);
    }
    return outcomes;
}
Also used : CollectionException(org.apache.uima.collection.CollectionException) DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData) HashSet(java.util.HashSet)

Example 15 with CollectionException

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

the class TestReaderSingleLabelDocumentReader 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();
    if (!suppress) {
        new TextClassificationTarget(jcas, 0, jcas.getDocumentText().length()).addToIndexes();
    }
}
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)

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