Commit 8b5afb3c authored by Manuel  Segimon's avatar Manuel Segimon
Browse files

Work in progress

parent 3328321e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -63,6 +63,13 @@ public class Corrector {
        // Divide sentence into words
        String[] words = inputSentence.split(" ");

        // Check if all words are in the trie
        for (int i = 0; i < words.length; i++) {
            if (!detector.containsWord(words[i])) {
                continue;
            }
        }

        List<String> sentences = generateSentences(words);

        // Use a priority queue to store sentences along with their scores
+10 −0
Original line number Diff line number Diff line
@@ -24,6 +24,16 @@ public class TrieNode implements Serializable, Cloneable {
        past.childCounts += 1;
    }

    public boolean containsWord(String word) {
        return this.children.containsKey(word);
    }

    public String findClosestWord(String word) {
        String[] children = this.children.keySet().toArray(new String[0]);

        return "";
    }

    public float probability(String phrase) {
        String[] words = phrase.split(" ");
        if (words.length <= 1) { // If word does not exist in trie