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
20 POINTS!! PLEASE HELP! WILL MARK BRAINLIEST
bixtya [17]

Writers or speakers usually use allegories as literary devices or as rhetorical devices that convey semi-hidden or complex meanings through symbolic figures, actions, imagery, or events, which together create the moral, spiritual, or political meaning the author wishes to convey.

3 0
3 years ago
Read 2 more answers
Language that is not part of the Indo-European family developed in _____.
deff fn [24]
Italy ...............................???????????
7 0
3 years ago
Which of the followings best states one of the central ideas of the article?
vodomira [7]

Answer:

picture?

Explanation:

7 0
3 years ago
Write an argumentative essay (4 PARAGRAPHS) on whether or not the United States should keep producing pennies or stop using them
frosja888 [35]

Answer:

I personally believe that the United States should not continue producing pennies. I think this because the use of pennies are decressing in numbers, think about it when was the last time you have used one? Pennies are worth one cent, and is simply not useful to today's society.

Every year money is spent, and wasted on producing pennies just for it to go to waste. It has been reported that in 2016 that an estimated $62 million in pennies are lost every year in circulation. To make a single penny cost the goverment 2 cents, and they make millions and millions of pennies each year, this means money is being thrown away each year.

Pennies are made out of zinc and copper, and if you didn'y know zinc mining has a negitive environmental impact. Zinc leaches into the surrounding soil and water streams. Letting this chemical element into water streams could cause health concerns. Some of these health concerns include slow growth in infants and children, delayed sexual development in adolescents, and impotence in men. Zinc deficiency also causes hair loss, diarrhea, eye, and skin sores, and loss of appetite.

Lastly, pennies have no purchasing power. Now and days you can not purchase anything for less than 2 dollars. Back in the 1900s, it was useful but currently, in 2021 there is nothing you can do with it. Discontinuing pennies will not only reduce the use of zinc in our water but save us money.

7 0
3 years ago
Describe moshe the beadle pages 1-20
miv72 [106K]

Answer:

Describe the character Moshe the Beadle. Moshe is awkward, clownish, shy, doesn't talk much but sings, deeply spiritual, very poor, and the community likes him.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Explain three harmful effects of poverty on one's personal
    8·1 answer
  • Multiple Choice: Please select the best answer and click "submit."
    7·2 answers
  • A ______showcases a writer’s point of view on a real-life personal experience
    7·1 answer
  • Where is the Raven at the end of the poem (stanza 18)? What does the Ravens presence tell the reader about the narrators grief?
    8·1 answer
  • Read the passage from Animal Farm.
    14·1 answer
  • Read this passage from "Notes of a Native Son": When [my father] was dead I realized that I had hardly ever spoken to him. When
    14·2 answers
  • What is the best reference source to find the meaning of the word flume
    15·1 answer
  • In 3-5 sentences respond. How can a person's decisions and actions change his/her life?
    13·2 answers
  • Three subject verb disagreements
    11·1 answer
  • Identify the oxymoron.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!