File size: 1,185 Bytes
6f3ebfa | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | package org.maltparser.concurrent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.maltparser.core.exception.MaltChainedException;
public class MaltParserRunnable implements Runnable {
private final List<String[]> inputSentences;
private List<String[]> outputSentences;
private final ConcurrentMaltParserModel model;
public MaltParserRunnable(List<String[]> sentences, ConcurrentMaltParserModel _model) {
this.inputSentences = new ArrayList<String[]>(sentences);
this.outputSentences = null;
this.model = _model;
}
public void run() {
try {
outputSentences = model.parseSentences(inputSentences);
} catch (MaltChainedException e) {
e.printStackTrace();
}
// for (int i = 0; i < inputSentences.size(); i++) {
// try {
// outputSentences.add(model.parseTokens(inputSentences.get(i)));
// } catch (MaltChainedException e) {
// e.printStackTrace();
// }
// }
}
public List<String[]> getOutputSentences() {
if (outputSentences == null) {
return Collections.synchronizedList(new ArrayList<String[]>());
}
return Collections.synchronizedList(new ArrayList<String[]>(outputSentences));
}
}
|