use of org.dkpro.tc.api.type.JCasId 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.JCasId in project dkpro-tc by dkpro.
the class CrfSuiteLoadModelConnector method getInstancesInSequence.
private List<Instance> getInstancesInSequence(FeatureExtractorResource_ImplBase[] featureExtractors, JCas jcas, TextClassificationSequence sequence, boolean addInstanceId, int sequenceId) throws Exception {
List<Instance> instances = new ArrayList<Instance>();
int jcasId = JCasUtil.selectSingle(jcas, JCasId.class).getId();
List<TextClassificationTarget> seqTargets = JCasUtil.selectCovered(jcas, TextClassificationTarget.class, sequence);
for (TextClassificationTarget aTarget : seqTargets) {
Instance instance = new Instance();
if (addInstanceId) {
instance.addFeature(InstanceIdFeature.retrieve(jcas, aTarget, sequenceId));
}
// execute feature extractors and add features to instance
try {
for (FeatureExtractorResource_ImplBase featExt : featureExtractors) {
instance.addFeatures(((FeatureExtractor) featExt).extract(jcas, aTarget));
}
} catch (TextClassificationException e) {
throw new AnalysisEngineProcessException(e);
}
// set and write outcome label(s)
instance.setOutcomes(getOutcomes(jcas, aTarget));
instance.setJcasId(jcasId);
instance.setSequenceId(sequenceId);
instance.setSequencePosition(aTarget.getId());
instances.add(instance);
}
return instances;
}
use of org.dkpro.tc.api.type.JCasId in project dkpro-tc by dkpro.
the class TestFoldUtil method createJCasIdAnnotation.
private void createJCasIdAnnotation(JCas jcas) {
JCasId id = new JCasId(jcas);
id.setId(0);
id.addToIndexes();
}
use of org.dkpro.tc.api.type.JCasId in project dkpro-tc by dkpro.
the class FoldClassificationUnitCasMultiplier method assignNewId.
private void assignNewId(JCas copyJCas) {
JCasId jcasId = JCasUtil.selectSingle(copyJCas, JCasId.class);
jcasId.setId(subCASCounter);
}
Aggregations