use of org.dkpro.tc.ml.crfsuite.writer.CrfSuiteFeatureFormatExtractionIterator in project dkpro-tc by dkpro.
the class CrfSuiteLoadModelConnector method process.
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
try {
int sequenceId = 0;
List<Instance> instance = new ArrayList<>();
for (TextClassificationSequence seq : JCasUtil.select(jcas, TextClassificationSequence.class)) {
instance.addAll(getInstancesInSequence(featureExtractors, jcas, seq, true, sequenceId++));
}
CrfSuiteFeatureFormatExtractionIterator iterator = new CrfSuiteFeatureFormatExtractionIterator(instance);
// takes N sequences and classifies them - all results are hold in
// memory
StringBuilder output = new StringBuilder();
while (iterator.hasNext()) {
StringBuilder buffer = new StringBuilder();
int limit = 5000;
int idx = 0;
while (iterator.hasNext()) {
StringBuilder seqInfo = iterator.next();
buffer.append(seqInfo);
idx++;
if (idx == limit) {
break;
}
}
List<String> command = buildCommand();
StringBuilder out = runCommand(command, buffer.toString());
output.append(out);
}
setPredictedOutcome(jcas, output.toString());
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}
Aggregations