Пример #1
0
 public void calculateStatistics(Analysis analysis) {
   Iterator iter = completions.keySet().iterator();
   while (iter.hasNext()) {
     String key = (String) iter.next();
     WordEntry we = (WordEntry) completions.get(key);
     we.calculateStatistics(analysis);
   }
 }
Пример #2
0
 public void add(String word) {
   WordEntry we = (WordEntry) completions.get(word);
   if (we == null) {
     we = new WordEntry(word);
     completions.put(word, we);
   }
   we.inc();
   nEntries++;
 }
Пример #3
0
  public String choose() {
    int ran = Math.abs(Analysis.random.nextInt() % nEntries);
    Iterator iter = completions.keySet().iterator();
    int sum = 0;

    while (iter.hasNext()) {
      String key = (String) iter.next();
      WordEntry we = (WordEntry) completions.get(key);
      if (we == null) throw new NullPointerException();
      sum += we.getnEntries();
      if (ran <= sum) return we.word;
    }
    throw new NullPointerException("Cannot get here");
  }
Пример #4
0
 public void getMarkerWord(WordEntry we) {
   we.set(markerWord);
 }