use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class TestPairReader method getNext.
@Override
public void getNext(JCas jcas) throws IOException, CollectionException {
super.getNext(jcas);
JCasId id = new JCasId(jcas);
id.setId(jcasid++);
id.addToIndexes();
for (String outcomeValue : getTextClassificationOutcomes(jcas)) {
TextClassificationOutcome outcome = new TextClassificationOutcome(jcas);
outcome.setOutcome(outcomeValue);
outcome.addToIndexes();
}
// as we are creating more than one CAS out of a single file, we need to have different
// document titles and URIs for each CAS
// otherwise, serialized CASes will be overwritten
DocumentMetaData dmd = DocumentMetaData.get(jcas);
dmd.setDocumentTitle(dmd.getDocumentTitle() + "-" + fileOffset);
dmd.setDocumentUri(dmd.getDocumentUri() + "-" + fileOffset);
fileOffset++;
}
use of org.dkpro.tc.api.type.TextClassificationOutcome 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();
}
}
use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class ValidityCheckConnectorPost method checkErrorConditionMissingOutcomeForTargetIfUnitOrSequenceMode.
private void checkErrorConditionMissingOutcomeForTargetIfUnitOrSequenceMode(List<TextClassificationTarget> targets, List<TextClassificationOutcome> outcomes) throws AnalysisEngineProcessException {
// labeled with an outcome annotation
if (featureModeI == 2 || featureModeI == 4) {
if (targets.size() == 0) {
throw new AnalysisEngineProcessException(new TextClassificationException("Your experiment is supposed to have [+" + TextClassificationTarget.class.getName() + "] annotations, which are missing"));
} else {
if (targets.size() != outcomes.size()) {
throwException("Number of targets [" + targets.size() + "] != number of outcomes [" + outcomes.size() + "]");
}
for (int i = 0; i < targets.size(); i++) {
TextClassificationTarget t = targets.get(i);
TextClassificationOutcome o = outcomes.get(i);
if (t.getBegin() != o.getBegin() || t.getEnd() != o.getEnd()) {
throwException("Index of target and outcome do not match taget span: [" + t.getBegin() + " - " + t.getEnd() + "] != outcome span " + o.getBegin() + " - " + o.getEnd());
}
}
}
}
}
use of org.dkpro.tc.api.type.TextClassificationOutcome in project dkpro-tc by dkpro.
the class SingleLabelOutcomeAnnotator_ImplBase method process.
/**
* @param jcas
* the jcas object
* @throws AnalysisEngineProcessException
* exception in case of error
*/
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
TextClassificationOutcome outcome = new TextClassificationOutcome(jcas);
outcome.setOutcome(getTextClassificationOutcome(jcas));
outcome.setWeight(getTextClassificationOutcomeWeight(jcas));
outcome.addToIndexes();
}
use of org.dkpro.tc.api.type.TextClassificationOutcome 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();
}
Aggregations