コード例 #1
0
  public String choose(ArrayList al, int i) { // Choose next word based on
    Hashtable hm = maps[i]; // previous i words in al
    String prefix = Rewrite.concat(al, i);
    PrefixEntry e = (PrefixEntry) hm.get(prefix);

    if (e == null) return "";
    return e.choose();
  }
コード例 #2
0
 void add(String previous, String newWord, int n) { // "now is the" -> <PrefixEntry"time">
   Hashtable hm = maps[n];
   nEntries[n]++;
   PrefixEntry e = (PrefixEntry) hm.get(previous);
   if (e == null) {
     e = new PrefixEntry(previous);
     hm.put(previous, e);
   }
   e.add(newWord);
 }
コード例 #3
0
 public void calculateStatistics() { // Just a bunch of numbers
   for (int i = 0; i < Rewrite.MAX; i++) {
     markerWord = markerWord2;
     Hashtable hm = maps[i];
     Iterator iter = hm.keySet().iterator();
     while (iter.hasNext()) {
       String key = (String) iter.next();
       PrefixEntry e = (PrefixEntry) hm.get(key);
       e.calculateStatistics(this);
     }
   }
 }
コード例 #4
0
 public void dump() {
   System.out.println(this);
   for (int i = 0; i < Rewrite.MAX; i++) {
     Hashtable hm = maps[i];
     Iterator iter = hm.keySet().iterator();
     while (iter.hasNext()) {
       String key = (String) iter.next();
       PrefixEntry e = (PrefixEntry) hm.get(key);
       e.dump();
     }
     System.out.println("--------------------------------");
   }
 }