use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class VectorizationSeq2SeqOfLabel method processOutcome.
private void processOutcome(JCas aJCas) throws Exception {
List<AnnotationFS> sequenceAnnos = new ArrayList<AnnotationFS>(CasUtil.select(aJCas.getCas(), sequenceSpanType));
for (AnnotationFS s : sequenceAnnos) {
List<TextClassificationOutcome> instances = JCasUtil.selectCovered(aJCas, TextClassificationOutcome.class, s);
if (instances.isEmpty()) {
continue;
}
int i = 0;
for (; i < instances.size(); i++) {
TextClassificationOutcome tco = instances.get(i);
if (toInteger) {
writerSeqOutcome.write(outcomeMap.get(tco.getOutcome()).toString());
} else {
writerSeqOutcome.write(tco.getOutcome());
}
if (i + 1 >= maximumLength) {
break;
}
if (i + 1 < instances.size()) {
writerSeqOutcome.write(" ");
}
}
writerSeqOutcome.write(System.lineSeparator());
}
}
use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class VocabularyOutcomeCollector method collectOutcomes.
private void collectOutcomes(JCas aJCas) {
Collection<TextClassificationOutcome> tcos = JCasUtil.select(aJCas, TextClassificationOutcome.class);
for (TextClassificationOutcome o : tcos) {
String outcome = o.getOutcome();
outcomes.add(outcome);
}
}
use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class InstanceExtractor method getWeight.
private double getWeight(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 instance weight annotation present in current CAS.");
}
double weight = -1.0;
for (TextClassificationOutcome outcome : outcomes) {
weight = outcome.getWeight();
}
return weight;
}
use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class InstanceExtractor method getOutcomes.
public 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;
}
use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class SequenceOutcomeAnnotator_ImplBase method process.
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
for (TextClassificationTarget unit : JCasUtil.selectCovered(jcas, TextClassificationTarget.class, JCasUtil.selectSingle(jcas, TextClassificationSequence.class))) {
TextClassificationOutcome outcome = new TextClassificationOutcome(jcas, unit.getBegin(), unit.getEnd());
outcome.setOutcome(getTextClassificationOutcome(jcas, unit));
outcome.setWeight(getTextClassificationOutcomeWeight(jcas, unit));
outcome.addToIndexes();
}
}
Aggregations