Search in sources :

Example 51 with TextClassificationOutcome

use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.

the class ConversionAnnotator method process.

@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
    for (TextClassificationOutcome o : JCasUtil.select(aJCas, TextClassificationOutcome.class)) {
        POS p = new POS(aJCas, o.getBegin(), o.getEnd());
        String val = o.getOutcome();
        if (suffix != null && !suffix.isEmpty()) {
            val += suffix;
        }
        p.setPosValue(val);
        p.addToIndexes();
    }
}
Also used : POS(de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome)

Example 52 with TextClassificationOutcome

use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.

the class EachTokenAsUnitAnnotator method process.

@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
    List<Token> tokens = new ArrayList<Token>(JCasUtil.select(aJCas, Token.class));
    for (Token token : tokens) {
        TextClassificationTarget unit = new TextClassificationTarget(aJCas, token.getBegin(), token.getEnd());
        unit.setId(tcId++);
        unit.setSuffix(token.getCoveredText());
        unit.addToIndexes();
        TextClassificationOutcome outcome = new TextClassificationOutcome(aJCas, token.getBegin(), token.getEnd());
        outcome.setOutcome("X");
        outcome.addToIndexes();
    }
}
Also used : TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome) ArrayList(java.util.ArrayList) TextClassificationTarget(org.dkpro.tc.api.type.TextClassificationTarget) Token(de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)

Example 53 with TextClassificationOutcome

use of org.dkpro.tc.api.type.TextClassificationOutcome 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)

Example 54 with TextClassificationOutcome

use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.

the class SequenceOutcomeReader method setTextClassificationOutcome.

protected void setTextClassificationOutcome(JCas aJCas, String outcome, int begin, int end) throws IOException {
    TextClassificationOutcome tco = new TextClassificationOutcome(aJCas, begin, end);
    tco.setOutcome(outcome);
    tco.addToIndexes();
}
Also used : TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome)

Example 55 with TextClassificationOutcome

use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.

the class CrfSuiteLoadModelConnector method getOutcomes.

private List<String> getOutcomes(JCas jcas, AnnotationFS unit) throws TextClassificationException {
    Collection<TextClassificationOutcome> outcomes;
    if (unit == null) {
        outcomes = JCasUtil.select(jcas, TextClassificationOutcome.class);
    } else {
        outcomes = JCasUtil.selectCovered(jcas, TextClassificationOutcome.class, unit);
    }
    if (outcomes.size() == 0) {
        throw new TextClassificationException("No outcome annotations present in current CAS.");
    }
    List<String> stringOutcomes = new ArrayList<String>();
    for (TextClassificationOutcome outcome : outcomes) {
        stringOutcomes.add(outcome.getOutcome());
    }
    return stringOutcomes;
}
Also used : TextClassificationException(org.dkpro.tc.api.exception.TextClassificationException) TextClassificationOutcome(org.dkpro.tc.api.type.TextClassificationOutcome) ArrayList(java.util.ArrayList)

Aggregations

TextClassificationOutcome (org.dkpro.tc.api.type.TextClassificationOutcome)59 JCas (org.apache.uima.jcas.JCas)29 ArrayList (java.util.ArrayList)27 AnalysisEngine (org.apache.uima.analysis_engine.AnalysisEngine)19 TextClassificationTarget (org.dkpro.tc.api.type.TextClassificationTarget)18 Token (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token)16 CollectionReader (org.apache.uima.collection.CollectionReader)15 CollectionException (org.apache.uima.collection.CollectionException)9 CASException (org.apache.uima.cas.CASException)8 JCasId (org.dkpro.tc.api.type.JCasId)8 TextClassificationSequence (org.dkpro.tc.api.type.TextClassificationSequence)7 AnalysisEngineProcessException (org.apache.uima.analysis_engine.AnalysisEngineProcessException)6 Test (org.junit.Test)6 DocumentMetaData (de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)5 Sentence (de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence)5 File (java.io.File)5 IOException (java.io.IOException)4 ResourceInitializationException (org.apache.uima.resource.ResourceInitializationException)4 TextClassificationException (org.dkpro.tc.api.exception.TextClassificationException)4 HashSet (java.util.HashSet)3