final long startTime = System.currentTimeMillis();
final int contextSize = DEFAULT_CONTEXT_SIZE;
final List<RuleMatch> ruleMatches = new ArrayList<>();
int matchCount = 0;
int sentCount = 0;
final RuleAsXmlSerializer serializer = new RuleAsXmlSerializer();
final PrintStream out = new PrintStream(System.out, true, "UTF-8");
if (apiFormat) {
out.print(serializer.getXmlStart(null, null));
}
for (StringPair srcAndTrg : reader) {
final List<RuleMatch> curMatches = Tools.checkBitext(
srcAndTrg.getSource(), srcAndTrg.getTarget(),
srcLt, trgLt, bRules);
final List<RuleMatch> fixedMatches = new ArrayList<>();
for (RuleMatch thisMatch : curMatches) {
fixedMatches.add(
trgLt.adjustRuleMatchPos(thisMatch,
reader.getSentencePosition(),
reader.getColumnCount(),
reader.getLineCount(),
reader.getCurrentLine(), null));
}
ruleMatches.addAll(fixedMatches);
if (fixedMatches.size() > 0) {
if (apiFormat) {
final String xml = serializer.ruleMatchesToXmlSnippet(fixedMatches,
reader.getCurrentLine(), contextSize);
out.print(xml);
} else {
printMatches(fixedMatches, matchCount, reader.getCurrentLine(), contextSize);
matchCount += fixedMatches.size();
}
}
sentCount++;
}
displayTimeStats(startTime, sentCount, apiFormat);
if (apiFormat) {
out.print(serializer.getXmlEnd());
}
return ruleMatches.size();
}