/* LanguageTool, a natural language style checker
 * Copyright (C) 2019 Daniel Naber (http://www.danielnaber.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.dev;

import org.languagetool.Language;
import org.languagetool.Languages;
import org.languagetool.rules.patterns.AbstractPatternRule;
import org.languagetool.rules.patterns.FalseFriendRuleLoader;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class FalseFriendExporter {

  private final static String filename = 
          "/home/dnaber/lt/git/languagetool/languagetool-core/src/main/resources/org/languagetool/rules/false-friends.xml";

  public static void main(String[] args) throws IOException {
    Language l1 = Languages.getLanguageForShortCode("en");
    Language l2 = Languages.getLanguageForShortCode("de");
    listRuleMessages(l1, l2);
    //listRuleMessages(l2, l1);
  }
  
  private static void listRuleMessages(Language l1, Language l2) throws IOException {
    FalseFriendRuleLoader ruleLoader = new FalseFriendRuleLoader(null);
    List<AbstractPatternRule> rules = ruleLoader.getRules(new File(filename), l1, l2);
    int i = 1;
    for (AbstractPatternRule rule : rules) {
      System.out.println(i + ". " + rule.getMessage().
              replaceFirst("Hinweis: ", "").replaceAll("<suggestion>", "'").replaceAll("</suggestion>", "'"));
      i++;
    }
  }
}

@@ -1466,18 +1466,18 @@
 rtCode(%22
+d
 e
-n
 %22);%0A    
@@ -1517,34 +1517,34 @@
 geForShortCode(%22
-d
 e
+n
 %22);%0A    listRule
@@ -1755,12 +1755,10 @@
 der(
-nul
 l
+1
 );%0A 
@@ -1835,21 +1835,21 @@
 name), l
-1, l2
+2, l1
 );%0A    i

fix NPE; fix argument order