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