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();
}
}
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();
}
}
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();
}
}
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();
}
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;
}
Aggregations