Question: Last time I posted this question I was given a completely irrelevant answer. It has since been marked thumbs down twice and I have received

Last time I posted this question I was given a completely irrelevant answer. It has since been marked thumbs down twice and I have received no help. It honestly seemed like a robot responded the answer I was given made literally no sense with the question I provided. Also, no response has been given since being thumbsed down. I really don't know what to do and this problem is frustrating me a lot. Please can someone provide me actual real help?

/ Create a spell checker that find all "misspelled" words (e.g. non-existing words). // Compare performance of the TST and Trie on various dictionary sizes.Last time I posted this question I was given a completely irrelevantanswer. It has since been marked thumbs down twice and I have

// TODO: Create a Trie from the dictionary, and find all non-existing words in the input text file.

// TODO: Create a TST from the dictionary, and find all non-existing words in the input text file.

_____________________________________________________________________

Everything below was provided to me as a hint to solve the problem.

TrieFilter Summary: This function is responsible for adding elements to your Trie using the given function parameters. To do this you can use the books stdlib library. e.g. *(I left some blank for you to figure out) *

In input = new In(____); while (!input.isEmpty()) { TrieST.put(Input._____, _____); }

Once you initialize your Trie (using the dictionary_file) you can now do the same type of input for all the words in text_file. This is what you will use to filter all the words. For this, adding these words to a String array will help you. So then you can just simply iterate over them and modify your Trie.

TSTFilter You can essentially do the exact same thing you did for TrieFilter but you will have to create a TST object. To do this you can do something like:

TST tst = new TST();

Again, input your dictionary_file to your tst using stdlib, then do the same for your text_file in which you can store using an array. Once the words are in an array you can write a very simple iteration to filter words.

1 package algs52; // section 5.2 20 import java.util. HashSet; 3 import stdlib.*; 4 5 // Create a spell checker that find all "misspelled" words (e.g. non-existing words). 6 // Compare performance of the TST and Trie on various dictionary sizes. 7 8 // Download and install the following files into your algs4/data directory: 9 // - https://introcs.cs.princeton.edu/java/data/commonwords.txt 74K words 10 // - https://introcs.cs.princeton.edu/java/data/wordlist.txt 224K words 11 // - https://introcs.cs.princeton.edu/java/data/words.utf-8.txt 645K words 12 // 13 // Expected output should be similar in performance: 14 // 15 // Triest TST 16 // Words Time Words Time 17 // 23699 0.40 23699 0.18 43% 18 // 25913 0.53 25913 0.34 63% 19 // 18075 1.15 18075 0.86 74% 20 21 22 public class hw7 23 public 240 public static HashSet TrieFilter(String dictionary_file, String text_file) // TODO: Create a Trie from the dictionary, and find all non-existing words in the input text file. 28 HashSet filteredWords = new HashSet(); 29 return filteredWords; 30 31 320 public static HashSet TSTFilter(String dictionary_file, String text_file) 33 34 // TODO: Create a TST from the dictionary, and find all non-existing words in the input text file. 35 36 HashSet filteredWords = new HashSet(); 37 return filteredWords; 38 } 39 400 private static void runTest(String dictionary, String textfile) 41 { 42 Stopwatch stopwatch = new Stopwatch(); HashSet f1 = TrieFilter(dictionary, textfile); double t1 = stopwatch.elapsedTime(); 46 stopwatch = new Stopwatch(); 47 48 HashSet f2 = TSTFilter(dictionary, textfile); double t2 = stopwatch.elapsedTime(); 49 50 51 Stdout.printf("%100 %6.2f | %100 %6.2f $4d%% ", f1.size(), t1, f2.size(), t2, (int) (100* (t2/t1))); } 52 530 54 55 56 57 58 59 60 61 62 63 64 65 public static void main(String[] args) { String commonwords = "data/commonwords.txt"; String wordlist = "data/wordlist.txt"; String words - "data/words.utf-8.txt"; String textfile = "data/mobydick.txt"; Stdout.printf("%20s %165 ", "Triest | ", "TST"); Stdout.printf("%20s %20s ", "Words Time", "Words runTest (commonwords, textfile); runTest (wordlist, textfile); runTest (words, textfile); Time %"); 66 67 } 68 1 package algs52; // section 5.2 20 import java.util. HashSet; 3 import stdlib.*; 4 5 // Create a spell checker that find all "misspelled" words (e.g. non-existing words). 6 // Compare performance of the TST and Trie on various dictionary sizes. 7 8 // Download and install the following files into your algs4/data directory: 9 // - https://introcs.cs.princeton.edu/java/data/commonwords.txt 74K words 10 // - https://introcs.cs.princeton.edu/java/data/wordlist.txt 224K words 11 // - https://introcs.cs.princeton.edu/java/data/words.utf-8.txt 645K words 12 // 13 // Expected output should be similar in performance: 14 // 15 // Triest TST 16 // Words Time Words Time 17 // 23699 0.40 23699 0.18 43% 18 // 25913 0.53 25913 0.34 63% 19 // 18075 1.15 18075 0.86 74% 20 21 22 public class hw7 23 public 240 public static HashSet TrieFilter(String dictionary_file, String text_file) // TODO: Create a Trie from the dictionary, and find all non-existing words in the input text file. 28 HashSet filteredWords = new HashSet(); 29 return filteredWords; 30 31 320 public static HashSet TSTFilter(String dictionary_file, String text_file) 33 34 // TODO: Create a TST from the dictionary, and find all non-existing words in the input text file. 35 36 HashSet filteredWords = new HashSet(); 37 return filteredWords; 38 } 39 400 private static void runTest(String dictionary, String textfile) 41 { 42 Stopwatch stopwatch = new Stopwatch(); HashSet f1 = TrieFilter(dictionary, textfile); double t1 = stopwatch.elapsedTime(); 46 stopwatch = new Stopwatch(); 47 48 HashSet f2 = TSTFilter(dictionary, textfile); double t2 = stopwatch.elapsedTime(); 49 50 51 Stdout.printf("%100 %6.2f | %100 %6.2f $4d%% ", f1.size(), t1, f2.size(), t2, (int) (100* (t2/t1))); } 52 530 54 55 56 57 58 59 60 61 62 63 64 65 public static void main(String[] args) { String commonwords = "data/commonwords.txt"; String wordlist = "data/wordlist.txt"; String words - "data/words.utf-8.txt"; String textfile = "data/mobydick.txt"; Stdout.printf("%20s %165 ", "Triest | ", "TST"); Stdout.printf("%20s %20s ", "Words Time", "Words runTest (commonwords, textfile); runTest (wordlist, textfile); runTest (words, textfile); Time %"); 66 67 } 68

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!