1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
frosja888 [35]
3 years ago
11

For months, Robert had been taunting Saul, using words like

English
1 answer:
never [62]3 years ago
3 0

Answer

For this week's lab, you will use two of the classes in the Java Collection Framework:  and . You will use these classes to implement a spell checker.

this lab, you will need to use some of the methods that are defined in the Set interface. Recall that if set is a Set, then the following methods are defined:

-- Returns the number of items in the set.

-- Adds the item to the set, if it is not already there.

-- Check whether the set contains the item.-- Check whether the set is empty.

You will also need to be able to traverse a set, using either an iterator or a for-each loop.

Reading a Dictionary

The file words.txt (in the code directory) contains a list of English words, with one word on each line. You will look up words in this list to check whether they are correctly spelled. To make the list easy to use, you can store the words in a set. Since there is no need to have the words stored in order, you can use a HashSet for maximum efficiency.

Use a Scanner to read the file. You can create scanner, filein, for reading from a file with a statement such as:

                    filein = new Scanner

(new File("/classes/s09/cs225/words.txt"));

and that a file can be processed, token by token, in a loop such as:

while (filein.hasNext()) {

    String tk = filein.next();

    process(tk); // do something with the token

}

(For the wordlist file, a token is simply a word.)

Start your main program by reading the words from words.txt and storing them in a HashSet. For the purposes of this program, convert all words to lower case before putting them in the set. To make sure that you've read all the words, check the size of the set. (It should be 72875.) You could also use the contains method to check for the presence of some common word in the set.

Checking the Words in a File

Once you have the list of words in a set, it's easy to read the words from a file and check whether each word is in the set. Start by letting the user select a file. You can either let the user type the name of the file or you can use the following metho

       }

Use a Scanner to read the words from the selected file. In order to skip over any non-letter characters in the file, you can use the following command just after creating the scanner (where in is the variable name f

(In this statement, "[^a-zA-Z]+" is a regular expression that matches any sequence of one or more non-letter characters. This essentially makes the scanner treat any non-letter the way it would ordinarily treat a space.)

You can then go through the file, read each word (converting it to lower case) and check whether the set contains the word. At this point, just print out any word that you find that is not in the dictionary.

Providing a List of Possible Correct Spellings

A spell checker shouldn't just tell you what words are misspelled -- it should also give you a list of possible correct spellings for that word. Write  method

static TreeSet corrections(String badWord, HashSet dictionary)

that creates and returns a TreeSet containing variations on badWord that are contained in the dictionary. In your main program, when you find a word that is not in the set of legal words, pass that word to this method (along with the set). Take the return value and output any words that it contains; these are the suggested correct spellings of the misspelled word. Here, for example, is part of the output from a sample program when it was run with the HTML source of this page as inp

Explanation:

You might be interested in
Past simple Regular verbs exercises
Studentka2010 [4]

Answer:

<u>- ied:</u> cry, enjoy, bury, marry

<u>-ed only</u>: label, wait, stay, explain, fail, prefer

<u>- d only:</u> care, like, agree, use

<u>double consonant +- ed </u>: stop, jog, clap, hop

Explanation:

We form regular Past Simple verb forms by adding the termination <em>-ed </em>to the infinitive of the verb.

e.g. wait, stay, explain

However, there are some exceptions, as the result of the spelling rules.

If the verb ends in <em>-e</em>, we will add the termination <em>-d</em>:

e.g. care, like, use

If the verb ends in a vowel and a consonant, we double the consonant before <em>-ed</em>:

eg. stop, clap, hop

If the verb ends in consonant and <em>-y</em>, we take off the y and add <em>-ied</em>.

e.g.  cry, enjoy, marry

8 0
4 years ago
“That’s the problem. We let people say stuff, and they say it so much that it becomes okay to them and normal for us.”
solmaris [256]

Answer:

if you let someone badmouth you without you putting a stop to it, they will walk over you their whole lives.

Explanation:

what this is pretty much saying is okay for instance, someone always makes fun of you but you never stop it. you let them so they believe that you dont care and that its okay.

7 0
3 years ago
If people's circumstances are precarious, they *
UNO [17]

Answer:

Lack security and stability

Explanation:

To be precarious is to be uncertain or not secure

5 0
3 years ago
6. )A paragraph that uses transitional devises and varied sentence structures to show relationships between ideas has _____.
AlekseyPX
6. )A paragraph that uses transitional devises and varied sentence structures to show relationships between ideas has coherence.

e.coherence
6 0
4 years ago
What should be done to encorage students to involve themselves in more outdoor games??
Gnesinka [82]
1. Be your child's role model.
Whatever you do,your child will follow you.
2. Find fun ways to play outdoor games.
If s/he likes video games, make the outdoor game like a video game. 
7 0
3 years ago
Other questions:
  • Milk from what breed of cow tends to freeze last as the temperature drops?
    12·2 answers
  • Read the excerpt from "An Indian's View of Indian Affairs." My father was chief before me. When a young man, he was called Josep
    7·2 answers
  • Which character is described in these lines? "The man-ruler famous, The long-worthy atheling, sat very woful, Suffered great sor
    6·2 answers
  • In what ways do you expand your English vocabulary?
    11·1 answer
  • Which answer choice has the subordinate clause indicated (In the parenthesis)?
    14·1 answer
  • True or false Extemporaneous and impromptu speaking are the same thing.
    8·2 answers
  • Which sentence uses commas correctly?
    5·1 answer
  • Anybody Know This. ?
    11·1 answer
  • Report about an event I participated in
    5·1 answer
  • In "Daedalus and Icarus," Icarus likes feeling like a god as he flies—but he drowns at the end of the story. Based on this, what
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!