Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your Assignment - SpellChecker.java You are to write a program that implements a rudimentary spellchecker. It should use a inner class named Lexicon that is
Your Assignment - SpellChecker.java You are to write a program that implements a rudimentary spellchecker. It should use a inner class named Lexicon that is implemented as a Trie. The Lexicon Class A Trie is a tree where every node can have up to 26 children one for each letter of the alphabet. Below is a figure of a Trie containing just a few short words beginning with c, d, and e. The nodes that represent the end of words have concentric circles. In your Trie, each node should have an array of 26 children, as well as a boolean value, named something like isWord. isWord is set to true only if this node represents a word. Lexicon car cars cat cats do dog oar eat eats The Lexicon class has a constructor and one public method. You are, of course, free to use private helper methods. These will not be tested The constructor should read all the words from enablelaugmented.txt and build a Trie containing them. enablelaugmented.txt is a list of thousands of English words, that has been augmented with some contractions at the end, without the apostrophes. public boolean containsWord (String word) which returns true if the word is in the lexicon, false otherwise. Once the Trie is constructed, searching it is straightforward. Say we are searching for the word "cat". We start at the root, go to the c' subtree, go to its 'a' subtree and go to its subtree. At this point we look and see that the isWord is true, so we return true. That is "cat" is a word There are two ways that false may be returned. If we come to the '' node and isWord is false, then we return false. .We might also come to the point where there is no child node to move to. In the example above, if we search for "does" we will visit the d, subtree and its o' subtree, but there is no e' subtree from there. In this case, we also return false. Looking up words in a Trie is a O(k) operation where k is the number of letters in the word. Your Assignment - SpellChecker.java You are to write a program that implements a rudimentary spellchecker. It should use a inner class named Lexicon that is implemented as a Trie. The Lexicon Class A Trie is a tree where every node can have up to 26 children one for each letter of the alphabet. Below is a figure of a Trie containing just a few short words beginning with c, d, and e. The nodes that represent the end of words have concentric circles. In your Trie, each node should have an array of 26 children, as well as a boolean value, named something like isWord. isWord is set to true only if this node represents a word. Lexicon car cars cat cats do dog oar eat eats The Lexicon class has a constructor and one public method. You are, of course, free to use private helper methods. These will not be tested The constructor should read all the words from enablelaugmented.txt and build a Trie containing them. enablelaugmented.txt is a list of thousands of English words, that has been augmented with some contractions at the end, without the apostrophes. public boolean containsWord (String word) which returns true if the word is in the lexicon, false otherwise. Once the Trie is constructed, searching it is straightforward. Say we are searching for the word "cat". We start at the root, go to the c' subtree, go to its 'a' subtree and go to its subtree. At this point we look and see that the isWord is true, so we return true. That is "cat" is a word There are two ways that false may be returned. If we come to the '' node and isWord is false, then we return false. .We might also come to the point where there is no child node to move to. In the example above, if we search for "does" we will visit the d, subtree and its o' subtree, but there is no e' subtree from there. In this case, we also return false. Looking up words in a Trie is a O(k) operation where k is the number of letters in the word
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started