private void loadAndShowHyps() { if (selectHypFileUI.getSelectedHypFile() != null) { hypotheses = selectHypFileUI.getLoadedHyps(); Iterator hypothesisIterator = hypotheses.iterator(); showLoadedHypsUI.createTable(hypotheses.size()); int rowNumber = 0; while (hypothesisIterator.hasNext()) { Hypothesis hypothesis = (Hypothesis) hypothesisIterator.next(); showLoadedHypsUI.addHyp( rowNumber, hypothesis.getNumber(), hypothesis.getHypothesisText(), hypothesis.getScore()); rowNumber++; } showLoadedHypsUI.setInfoLabelText( "You selected " + selectHypFileUI.getSelectedHypFile().getName().toString() + " as the input file." + " I found " + hypotheses.size() + " hypotheses."); } else { showLoadedHypsUI.setInfoLabelText("No hypothesis file selected."); } }
private void scoreBySingleWords() { if (hypotheses == null) { scoreHypsByWordsUI.setInfoLabelText("No hyps loaded!"); hypotheses = getHypsFromFile(); } if (showWordsUI.getWordListTableModel() == null) { scoreHypsByWordsUI.setInfoLabelText("No word list 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."); } // load the scoring table as a HashMap Object[][] wordListTable = showWordsUI.getWordListTableModel().getAllWords(); int wordCount = showWordsUI.getWordListTableModel().getRowCount(); wordCodeMap = new HashMap(); for (int i = 0; i < wordCount; i++) { if (((Integer) wordListTable[i][3]).intValue() != 0) { wordCodeMap.put(wordListTable[i][0], wordListTable[i][3]); } } // make list of words words = new String[wordCodeMap.size() + 1]; Iterator wordIterator = wordCodeMap.keySet().iterator(); while (wordIterator.hasNext()) { String currentWord = (String) wordIterator.next(); int code = ((Integer) wordCodeMap.get(currentWord)).intValue(); words[code] = currentWord; } // score the hyps and display scoreHypsByWordsUI.createTable(hypotheses.size(), words); for (int i = 0; i < hypotheses.size(); i++) { Hypothesis hypothesis = (Hypothesis) hypotheses.get(i); int[] singleWordScores = hypothesis.scoreBySingleWords(wordCodeMap); scoreHypsByWordsUI.addHyp(i, hypothesis.getHypothesisText(), singleWordScores); } scoreHypsByWordsUI.setInfoLabelText( "I scored " + hypotheses.size() + " hypotheses with " + wordCodeMap.size() + " words."); }