コード例 #1
0
  private void showAndEditWords() {
    if (hypotheses != null) {
      Iterator hypothesisIterator = hypotheses.iterator();
      wordsAndCounts = new HashMap();
      while (hypothesisIterator.hasNext()) {
        Hypothesis hypothesis = (Hypothesis) hypothesisIterator.next();
        ArrayList wordSet = hypothesis.getWordSet();
        Iterator wordIterator = wordSet.iterator();
        while (wordIterator.hasNext()) {
          String wordText = (String) wordIterator.next();
          if (wordsAndCounts.containsKey(wordText)) {
            int oldCount = ((Integer) wordsAndCounts.get(wordText)).intValue();
            wordsAndCounts.put(wordText, new Integer(oldCount + 1));
          } else {
            wordsAndCounts.put(wordText, new Integer(1));
          }
        }
      }
      Iterator wordListIterator = wordsAndCounts.keySet().iterator();
      showWordsUI.createTable(wordsAndCounts.size());
      int rowNumber = 0;
      while (wordListIterator.hasNext()) {
        String wordText = (String) wordListIterator.next();
        int count = ((Integer) wordsAndCounts.get(wordText)).intValue();
        showWordsUI.addWord(rowNumber, wordText, count, "", 0);
        rowNumber++;
      }
      showWordsUI.setInfoLabelText("I found " + rowNumber + " words.");

    } else {
      showWordsUI.setInfoLabelText("No hypotheses loaded.");
      ArrayList allWords = getWordListFromFile();

      showWordsUI.createTable(allWords.size());
      for (int i = 0; i < allWords.size(); i++) {
        Word word = (Word) allWords.get(i);
        showWordsUI.addWord(i, word.getText(), word.getCount(), word.getGroup(), word.getCode());
      }
      showWordsUI.setInfoLabelText("I found " + allWords.size() + " words.");
    }
  }