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
ivanzaharov [21]
3 years ago
10

(Count the occurrences of words in a text file) Rewrite Listing 21.9 to read the text from a text file. The text file is passed

as a command-line argument. Words are delimited by whitespace characters, punctuation marks (, ; . : ?), quotation marks (' "), and parentheses. Count the words in a case-sensitive fashion (e.g., consider Good and good to be the same word). The words must start with a letter. Display the output of words in alphabetical order, with each word preceded by the number of times it occurs.
I ran my version of the program solution on its own Java source file to produce the following sample output:
C:\Users\......\Desktop>java CountOccurrenceOfWords CountOccurrenceOfWords.java
Display words and their count in ascending order of the words
1 a
1 alphabetical
1 an
2 and
3 args
2 as
1 ascending
1 catch
1 class
4 count
2 countoccurrenceofwords
1 create
1 display
1 else
3 entry
3 entryset
2 ex
1 exception
1 exit
1 file
2 filename
3 for
1 fullfilename
3 get
1 getkey
1 getvalue
1 hasnext
1 hold
5 i
3 if
2 import
2 in
3 input
2 int
1 io
3 java
6 key
3 length
2 line
1 main
3 map
1 matches
3 new
1 nextline
1 null
1 of
2 order
3 out
3 println
1 printstacktrace
2 public
2 put
2 scanner
1 set
1 split
1 static
5 string
4 system
2 the
1 their
1 to
1 tolowercase
2 tree
6 treemap
2 trim
1 try
1 util
1 value
1 void
1 while
9 words
C:\Users\......\Desktop>
Computers and Technology
1 answer:
Oksanka [162]3 years ago
3 0

Answer:

Explanation:

The following is written in Java. It uses File input, to get the file and read every line in the file. It adds all the lines into a variable called fullString. Then it uses regex to split the string into separate words. Finally, it maps the words into an array that counts all the words and how many times they appear. A test case has been created and the output can be seen in the attached image below. Due to technical difficulties I have added the code as a txt file below.

You might be interested in
"what is the name of the ipsec configuration file"
kifflom [539]
Ipsec.conf file. This file is found in the /etc/ directory
5 0
3 years ago
even if we reach that state where an AI can behave as human does,how do we measure if AI is acting like a human?
xxTIMURxx [149]

A person can be able to measure if AI is acting like a human by the use of   Turing test.

<h3>How do we measure of artificial intelligence is acting like a human?</h3>

One can measure if AI is  Acting humanly via the use of a human who is said to interrogates the program and also the use of another person through the use of a terminal simultaneously.

Note that If after some amount of time or period, the interrogator is said to be unable to tell which is which, the program is said to have passed. To pass this test it is one that needs natural language processing.

Hence, A person can be able to measure if AI is acting like a human by the use of Turing test.

Learn more about AI from

brainly.com/question/25523571

#SPJ1

4 0
1 year ago
In what way do networks help to protect data
Aleksandr-060686 [28]

One way that computer networks help to protect data is by backing up the data.

Computer networks are normally formatted to automatically back up all of the data that is stored on them. This protects the data in case of any type of computer system failure.

5 0
3 years ago
Which type of network cover a large geographical area and usually consists of several smaller networks, which might use differen
nlexa [21]

Answer: WIDE AREA NETWORK (WAN)

Explanation: hopes this helps

7 0
3 years ago
Which header will be the largest?<br><br> Hello<br><br> Hello<br><br> Hello<br><br> Hello
geniusboy [140]

Answer:  

Bye

bye

bye

bye

Explanation:

4 0
2 years ago
Read 2 more answers
Other questions:
  • Properly defined the primary part of a CPU​
    5·1 answer
  • When planning the structure of a spreadsheet, columns are for _______ items and rows are for _______ items.
    5·2 answers
  • We will pass in a value N. Write a program that outputs the complete Fibonacci sequence for N iterations. Important: If N is 0,
    13·1 answer
  • Which of the following is the primary medium for beach erosion?
    12·1 answer
  • Which wildcard characters will return a single character when using the Find dialog box?
    6·2 answers
  • What type of undocumented yet benign hidden feature launches after a special set of commands, key combinations, or mouse clicks?
    15·1 answer
  • What is the point of brainy when other people have to answer your questions but not the cumputer
    9·1 answer
  • Why is it important to think about the programming language to use?
    6·1 answer
  • Need Help Please
    7·1 answer
  • A row-level trigger requires use of the _____ keywords and is executed once for each row affected by the triggering statement.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!