public void savePairsAsArff() {
    TreeMap pairMap = new TreeMap();
    if (hypotheses == null) {
      saveWordPairsAsArffUI.setInfoLabelText("No hyps loaded!");
      hypotheses = getHypsFromFile();
    }
    if ((wordCodeMap == null) || (wordCodeMap.size() == 0)) {
      wordCodeMap = new HashMap();
      saveWordPairsAsArffUI.setInfoLabelText("No word list loaded!");
      ArrayList wordList = getWordListFromFile();
      for (int i = 0; i < wordList.size(); i++) {
        Word word = (Word) wordList.get(i);
        wordCodeMap.put(word.getText(), new Integer(word.getCode()));
      }
    }
    if (showWordDoublesUI.getPairMap().size() == 0) {
      saveWordPairsAsArffUI.setInfoLabelText("No word pairs loaded!");
      pairMap = getPairsFromFile();
    } else {
      pairMap = showWordDoublesUI.getPairMap();
    }

    Iterator hypIterator = hypotheses.iterator();
    TreeMap scoreMap = new TreeMap();
    TreeMap scoreCounts = new TreeMap();
    while (hypIterator.hasNext()) {
      Hypothesis hypothesis = (Hypothesis) hypIterator.next();
      Integer score = new Integer(hypothesis.getScore());
      scoreMap.put(score, score);
      if (!scoreCounts.containsKey(score)) {
        scoreCounts.put(score, new Integer(1));
      } else {
        int oldCount = ((Integer) scoreCounts.get(score)).intValue();
        scoreCounts.put(score, new Integer(oldCount + 1));
      }
    }

    saveWordPairsAsArffUI.createTable(scoreMap.size());
    Iterator scoreIterator = scoreMap.keySet().iterator();
    int rowNumber = 0;
    while (scoreIterator.hasNext()) {
      Integer currentScore = (Integer) scoreIterator.next();
      saveWordPairsAsArffUI.addScore(
          rowNumber, currentScore.intValue(), ((Integer) scoreCounts.get(currentScore)).intValue());
      rowNumber++;
    }

    saveWordPairsAsArffUI.setHypsAndScores(hypotheses, wordCodeMap, pairMap);

    saveWordPairsAsArffUI.setInfoLabelText("Optionally edit the scores and" + " save the file.");
  }
 public void showWordPairs() {
   wordPairHistogram = calculateWordDoublesUI.getHistogram();
   showWordDoublesUI.createTable(wordPairHistogram.keySet().size(), numCodes, pairs, words);
   Iterator histoIterator = wordPairHistogram.keySet().iterator();
   int rowNumber = 0;
   while (histoIterator.hasNext()) {
     Integer key = (Integer) histoIterator.next();
     showWordDoublesUI.addData(
         rowNumber, key.intValue(), ((Integer) wordPairHistogram.get(key)).intValue());
     rowNumber++;
   }
   showWordDoublesUI.setInfoLabelText(
       "There were " + (numCodes * numCodes) + " possible word pairs.");
 }