Commit 00dcb616 authored by Manuel  Segimon's avatar Manuel Segimon
Browse files

Checker logic to display if sentence is good in MainApp

parent c05629c5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ public class Corrector {
        boolean originalInTop5 = false;
        for (String sentence : topSentences) {
            sentence = sentence.split(" \\| Score: ")[0]; // Remove score
            System.out.println(sentence);
            //System.out.println(sentence);
            if (sentence != null && sentence.equals(inputSentence)) {
                originalInTop5 = true;
                break;
@@ -194,7 +194,7 @@ public class Corrector {
        sortedList.sort(Map.Entry.comparingByValue());

        for (Map.Entry<String, Integer> entry : sortedList) {
            System.out.println("    " + entry.getKey() + " | Changes: " + entry.getValue());
            System.out.println(">> " + entry.getKey() + " | Changes: " + entry.getValue());
        }
    }

+7 −3
Original line number Diff line number Diff line
@@ -186,11 +186,15 @@ public class MainApp extends JFrame {
                    }
                }

                if (worstPhrase != null) {
                if (worstPhrase != null && lowestScore > 10.0) { // Check if the worst phrase has a low enough score
                    // Append to the result with annotations
                    result.append("\nSentence: ").append(sentence)
                            .append("\n>> Worst Phrase: ").append(worstPhrase)
                            .append(" (Score: ").append(lowestScore).append(")\n");
                } else {
                    result.append("\nSentence: ").append(sentence)
                            .append("\n>> No worst phrase found (with low enough score), the sentence is grammatically correct.\n");
                    worstPhrases[sentences.indexOf(sentence)] = "";
                }
            }

@@ -202,7 +206,7 @@ public class MainApp extends JFrame {
            for (String phrase : worstPhrases) {
                phrase = phrase.replaceAll("\"", "");
                //System.out.println(phrase);
                if (phrase != null) {
                if (phrase != null && !phrase.isEmpty()) {
                    //System.out.println(resultArea.getText());
                    int start = resultArea.getText().indexOf(phrase);
                    if (start != -1) {
@@ -254,7 +258,7 @@ public class MainApp extends JFrame {

        int i = 1;
        for (Map.Entry<String, Integer> entry : sortedList) {
            result.append("    " + i + ") " + entry.getKey() + " | Changes: " + entry.getValue() + "\n");
            result.append(">> " + entry.getKey() + " | Changes: " + entry.getValue() + "\n");
            i++;
        }
    }