/* LanguageTool, a natural language style checker 
 * Copyright (C) 2012 Marcin Miłkowski (http://www.languagetool.org)
 * 
 * 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.rules.ca;

import java.io.IOException;
import java.util.ResourceBundle;

import org.languagetool.Language;
import org.languagetool.rules.spelling.morfologik.MorfologikSpellerRule;

public final class MorfologikCatalanSpellerRule extends MorfologikSpellerRule {

  //private static final String RESOURCE_FILENAME = "/ca/hunspell/ca_ES.dict";
  private static final String RESOURCE_FILENAME = "/ca/catalan.dict";
  //private static final String FILE_NAME = "/ca/frequentwords.txt";
  //private static final String FILE_ENCODING = "utf-8";
  //private final List<String> frequentWords;
  
  public MorfologikCatalanSpellerRule(ResourceBundle messages,
                                      Language language) throws IOException {
    super(messages, language);
    this.setIgnoreTaggedWords();
    //frequentWords=loadWords(FILE_NAME);
  }

  @Override
  public String getFileName() {
    return RESOURCE_FILENAME;
  }

  @Override
  public String getId() {
    return "MORFOLOGIK_RULE_CA_ES";
  }
  
 /* @Override
  protected List<String> orderSuggestions(List<String> suggestions, String word) {
    List<String> orderedSuggestions1 = new ArrayList<String>();
    List<String> orderedSuggestions2 = new ArrayList<String>();
    for (String suggestion : suggestions) {
        if (frequentWords.contains(suggestion)) {
          orderedSuggestions1.add(suggestion);
        } else {
          orderedSuggestions2.add(suggestion);
        }      
    }
    List<String> orderedSuggestions = new ArrayList<String>();
    orderedSuggestions.addAll(orderedSuggestions1);
    orderedSuggestions.addAll(orderedSuggestions2);
    return orderedSuggestions;
  }*/
  
  /**
   * Load words.
   */
  /*private List<String> loadWords(String fileName) throws IOException {
    final ArrayList<String> list = new ArrayList<String>();
    final InputStream inputStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(fileName);
    final Scanner scanner = new Scanner(inputStream, FILE_ENCODING);
    try {
      while (scanner.hasNextLine()) {
        final String line = scanner.nextLine().trim();
        if (line.length() < 1) {
          continue;
        }
        if (line.charAt(0) == '#') {      // ignore comments
          continue;
        }
        list.add(line);
      }
    } finally {
      scanner.close();
    }
    return list;
  }*/
  

}

@@ -1183,334 +1183,77 @@
 %0D%0A  
-//private static final String RESOURCE_FILENAME = %22/ca/hunspell/ca_ES.dict%22;%0D%0A  private static final String RESOURCE_FILENAME = %22/ca/catalan.dict%22;%0D%0A  //private static final String FILE_NAME = %22/ca/frequentwords.txt%22;%0D%0A  //private static final String FILE_ENCODING = %22utf-8%22;%0D%0A  //private final List%3CString%3E frequentWords;%0D%0A  
+private static final String RESOURCE_FILENAME = %22/ca/catalan.dict%22;%0D%0A
 %0D%0A  
@@ -1316,47 +1316,8 @@
 ges,
-%0D%0A                                     
  Lan
@@ -1331,16 +1331,23 @@
 anguage)
+%0D%0A     
  throws 
@@ -1431,51 +1431,8 @@
 );%0D%0A
-    //frequentWords=loadWords(FILE_NAME);%0D%0A
   %7D%0D
@@ -1599,1411 +1599,12 @@
 %22;%0D%0A
+
   %7D%0D
-%0A  %0D%0A /* @Override%0D%0A  protected List%3CString%3E orderSuggestions(List%3CString%3E suggestions, String word) %7B%0D%0A    List%3CString%3E orderedSuggestions1 = new ArrayList%3CString%3E();%0D%0A    List%3CString%3E orderedSuggestions2 = new ArrayList%3CString%3E();%0D%0A    for (String suggestion : suggestions) %7B%0D%0A        if (frequentWords.contains(suggestion)) %7B%0D%0A          orderedSuggestions1.add(suggestion);%0D%0A        %7D else %7B%0D%0A          orderedSuggestions2.add(suggestion);%0D%0A        %7D      %0D%0A    %7D%0D%0A    List%3CString%3E orderedSuggestions = new ArrayList%3CString%3E();%0D%0A    orderedSuggestions.addAll(orderedSuggestions1);%0D%0A    orderedSuggestions.addAll(orderedSuggestions2);%0D%0A    return orderedSuggestions;%0D%0A  %7D*/%0D%0A  %0D%0A  /**%0D%0A   * Load words.%0D%0A   */%0D%0A  /*private List%3CString%3E loadWords(String fileName) throws IOException %7B%0D%0A    final ArrayList%3CString%3E list = new ArrayList%3CString%3E();%0D%0A    final InputStream inputStream = JLanguageTool.getDataBroker().getFromResourceDirAsStream(fileName);%0D%0A    final Scanner scanner = new Scanner(inputStream, FILE_ENCODING);%0D%0A    try %7B%0D%0A      while (scanner.hasNextLine()) %7B%0D%0A        final String line = scanner.nextLine().trim();%0D%0A        if (line.length() %3C 1) %7B%0D%0A          continue;%0D%0A        %7D%0D%0A        if (line.charAt(0) == '#') %7B      // ignore comments%0D%0A          continue;%0D%0A        %7D%0D%0A        list.add(line);%0D%0A      %7D%0D%0A    %7D finally %7B%0D%0A      scanner.close();%0D%0A    %7D%0D%0A    return list;%0D%0A  %7D*/%0D%0A  %0D
 %0A%0D%0A%7D

Clean up code