/** * Applies smoothing and compares two sentences * * @param sentence1 Sentence 1 * @param sentence2 Sentence 2 * @param operation Type of smoothing to apply * @param smoothing Object of class {@link Smoothing} */ private void compareSentence( final String sentence1, final String sentence2, final Models operation, final Smoothing smoothing) { // Do smoothing for each sentence System.out.println(operation); final double comp1 = smoothing.doSmoothing(sentence1, operation); System.out.println("Sentence 1 Probability: " + comp1); final double comp2 = smoothing.doSmoothing(sentence2, operation); System.out.println("Sentence 2 Probability: " + comp2); // Compute result String output = ""; if (comp1 > comp2) { output = "S1 is more probable"; } else if (comp1 < comp2) { output = "S2 is more probable"; } else { output = "S1 and S2 are equally probable"; } System.out.println(output + "\n"); }
/** * Display probability table for sentences * * @param sentence1 Sentence 1 * @param sentence2 Sentence 2 * @param smoothing Object of class {@link Smoothing} * @param smoothingType Type of smoothing */ private void displayTable( final String sentence1, final String sentence2, final Smoothing smoothing, final Models smoothingType) { System.out.println("\nS1: " + sentence1 + "\n"); smoothing.displayProbabilityTable(sentence1, smoothingType); System.out.println("\nS2: " + sentence2 + "\n"); smoothing.displayProbabilityTable(sentence2, smoothingType); System.out.println(); }