コード例 #1
0
  public void testMostCommonCharIn() {
    FileResource fr = new FileResource("dictionaries/English");
    HashSet<String> dict = readDictionary(fr);
    System.out.println("English dict has " + dict.size() + " entries");

    char mostCommon = mostCommonCharIn(dict);
    System.out.println(" most common char: " + mostCommon);

    FileResource fr1 = new FileResource("dictionaries/Spanish");
    HashSet<String> dict1 = readDictionary(fr1);
    System.out.println("Spanish dict has " + dict1.size() + " entries");

    mostCommon = mostCommonCharIn(dict1);
    System.out.println(" most common char: " + mostCommon);
  }
コード例 #2
0
  public void testReadDictionary() {

    FileResource fr = new FileResource("dictionaries/English");
    HashSet<String> dict = readDictionary(fr);
    System.out.println("dict has " + dict.size() + " entries");

    Iterator<String> it = dict.iterator();
    for (int i = 0; i < 25; i++) {
      if (it.hasNext()) {
        System.out.println(i + "\t" + it.next());
      }
    }
  }