@@ -0,0 +1,2228 @@
+/* LanguageTool, a natural language style checker %0A * Copyright (C) 2013 Daniel Naber (http://www.danielnaber.de)%0A * %0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301%0A * USA%0A */%0Apackage org.languagetool.dev.dumpcheck;%0A%0Aimport org.languagetool.Language;%0Aimport org.languagetool.rules.RuleMatch;%0Aimport org.languagetool.rules.patterns.AbstractPatternRule;%0Aimport org.languagetool.tools.ContextTools;%0A%0Aimport java.util.List;%0A%0A/**%0A * Print compact rule matches to STDOUT.%0A * @since 3.3%0A */%0Aclass CompactStdoutHandler extends ResultHandler %7B%0A%0A  private final ContextTools contextTools = new ContextTools();%0A%0A  CompactStdoutHandler(int maxSentences, int maxErrors) %7B%0A    super(maxSentences, maxErrors);%0A    contextTools.setContextSize(70);%0A    contextTools.setErrorMarkerStart(%22**%22);%0A    contextTools.setErrorMarkerEnd(%22**%22);%0A  %7D%0A%0A  @Override%0A  protected void handleResult(Sentence sentence, List%3CRuleMatch%3E ruleMatches, Language language) %7B%0A    if (ruleMatches.size() %3E 0) %7B%0A      for (RuleMatch match : ruleMatches) %7B%0A        String ruleId = match.getRule().getId();%0A        if (match.getRule() instanceof AbstractPatternRule) %7B%0A          AbstractPatternRule pRule = (AbstractPatternRule) match.getRule();%0A          ruleId += %22%5B%22 + pRule.getSubId() + %22%5D%22;%0A        %7D%0A        System.out.println(ruleId + %22: %22 + contextTools.getContext(match.getFromPos(), match.getToPos(), sentence.getText()));%0A        checkMaxErrors(++errorCount);%0A      %7D%0A    %7D%0A    checkMaxSentences(++sentenceCount);%0A  %7D%0A%0A  @Override%0A  public void close() throws Exception %7B%0A  %7D%0A%7D%0A

print rule matches in a compact way: useful to sort by rule id, e.g. for fighting false alarms