Loading src/main/java/edu/bu/LanguageCorrection/MainApp.java +7 −4 Original line number Diff line number Diff line Loading @@ -281,6 +281,7 @@ public class MainApp extends JFrame { // Add a pop up to input the best correction for each sentence TrieNode node = corrector.getDetector(); boolean changeMade = false; for (String sentence : sentences) { String sentenceNew = sentence.replaceAll("[^a-zA-Z0-9\\s]", ""); String[] corrected = corrector.correct(sentenceNew); Loading Loading @@ -312,16 +313,18 @@ public class MainApp extends JFrame { String[] words = phrase.split(" "); node.insert(words); } changeMade = true; } else { System.out.println("No correction selected"); } } // Serialize the trie if (changeMade) { byte[] serialized = node.serialize(); byte[] compressed = compress(serialized); writeToFile(compressed, "metadata.ser"); } } catch (Exception e) { resultArea.setText("Error: " + e.getMessage()); } Loading src/main/java/edu/bu/LanguageCorrection/TrieNode.java +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class TrieNode implements Serializable, Cloneable { logProb += Math.log((probability(currentPhrase))); } float perplexity = (float) Math.pow(2, -logProb); //System.out.println("Perplexity of phrase (" + phrase + ") : " + perplexity); System.out.println("Perplexity of phrase (" + phrase + ") : " + perplexity); return perplexity; } Loading Loading
src/main/java/edu/bu/LanguageCorrection/MainApp.java +7 −4 Original line number Diff line number Diff line Loading @@ -281,6 +281,7 @@ public class MainApp extends JFrame { // Add a pop up to input the best correction for each sentence TrieNode node = corrector.getDetector(); boolean changeMade = false; for (String sentence : sentences) { String sentenceNew = sentence.replaceAll("[^a-zA-Z0-9\\s]", ""); String[] corrected = corrector.correct(sentenceNew); Loading Loading @@ -312,16 +313,18 @@ public class MainApp extends JFrame { String[] words = phrase.split(" "); node.insert(words); } changeMade = true; } else { System.out.println("No correction selected"); } } // Serialize the trie if (changeMade) { byte[] serialized = node.serialize(); byte[] compressed = compress(serialized); writeToFile(compressed, "metadata.ser"); } } catch (Exception e) { resultArea.setText("Error: " + e.getMessage()); } Loading
src/main/java/edu/bu/LanguageCorrection/TrieNode.java +1 −1 Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ public class TrieNode implements Serializable, Cloneable { logProb += Math.log((probability(currentPhrase))); } float perplexity = (float) Math.pow(2, -logProb); //System.out.println("Perplexity of phrase (" + phrase + ") : " + perplexity); System.out.println("Perplexity of phrase (" + phrase + ") : " + perplexity); return perplexity; } Loading