ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime()
.availableProcessors());
progressBar.setValue(0);
for (int j = 0; j < graphList.size(); j++) {
final int currentJ = j;
Graph template = graphList.get(j);
if (pattern.getName().equals(template.getName())) {
continue;
}
final AbstractMatcher matcher = MatcherFactory.createMatcher(options.getMatcherID(), pattern,
template);
Runnable matchingTask = new Runnable() {
@Override
public void run() {
try {
MatchingResult matchingResult = matcher.match(options);
matchingResults[currentJ] = matchingResult;
synchronized (progressBar) {
progressBar.setValue(progressBar.getValue() + 1);
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
executorService.submit(matchingTask);
}
try {
executorService.shutdown();
executorService.awaitTermination(1, TimeUnit.DAYS);
} catch (InterruptedException e) {
e.printStackTrace();
}
Arrays.sort(matchingResults, new Comparator<MatchingResult>() {
@Override
public int compare(MatchingResult o1, MatchingResult o2) {
if (o1 == null) {
return 1;
}
if (o2 == null) {
return -1;
}
if (o1.getQuality() > o2.getQuality()) {
return -1;
} else {
return 1;
}
}
});
NumberFormat format = NumberFormat.getInstance();
format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(2);
System.out.println("Matching Qualities: " + pattern.getName());
boolean bestTemplateIsCorrect = pattern.equalMeaning(matchingResults[0].getTemplate());
if (bestTemplateIsCorrect) {
bestPositive++;
}
int tp = 0, tn = 0, fp = 0, fn = 0;
boolean firstNegativeFound = false;
for (int i = 0; i < matchingResults.length; i++) {
if (matchingResults[i] == null) {
continue;
}
Graph template = matchingResults[i].getTemplate();
double quality = matchingResults[i].getQuality();
boolean equal = pattern.equalMeaning(template);
if (!equal) {
firstNegativeFound = true;
}