Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a command line application (Problem2. java that indexes the words contained in a text file. Your program should go through the input file line

image text in transcribed

Write a command line application (Problem2. java that indexes the words contained in a text file. Your program should go through the input file line by line. For each line, it extracts each word, and insert that word, along with it's line number into an AVL tree. Each element of the AVL tree should contain a unique word and a linked list of line numbers where that word occurs -note that you must include the underFlo Exception class, which is available here a Modify this fie directly and add the following functionality: Make sure the elements in the Av Tree are pairs of a word and a linked lists storing line numbers. The relative order of elements in the data structure should depend on the word only Write the method public void indexlord(String word,int line) that adds an occurrence of the word word in ine line. If a word already exists in the AVL Tree, simply add the new line number to the existing node. If a word appears on the same line twice, it should only have one entry in the list for that line. Write the method public List getlinesForWord(String word) that looks up a word and returns a list of lines in which it occurs. Write the method public void printIndexO the prints out each unique word that is stored in the Avl tree along with a list of line numbers in which that word appears. Finally, the main method in Problem2.java should create an instance of your AvlTree and uses it to indexes the words contained in a text file (provided to the program as a command line argument). Ignore case in the input text insert everything as lower case), and ignore all punctuation. When indexing has finished, the program should call the printIndex method to display a list of unique words in the text file and the line numbers in which that word occurs UnderFlowException class *Exception class for access in empty containers such as stacks, queues, and priority queues. *author Mark Allen Weiss public class UnderflowException extends RuntimeException Write a command line application (Problem2. java that indexes the words contained in a text file. Your program should go through the input file line by line. For each line, it extracts each word, and insert that word, along with it's line number into an AVL tree. Each element of the AVL tree should contain a unique word and a linked list of line numbers where that word occurs -note that you must include the underFlo Exception class, which is available here a Modify this fie directly and add the following functionality: Make sure the elements in the Av Tree are pairs of a word and a linked lists storing line numbers. The relative order of elements in the data structure should depend on the word only Write the method public void indexlord(String word,int line) that adds an occurrence of the word word in ine line. If a word already exists in the AVL Tree, simply add the new line number to the existing node. If a word appears on the same line twice, it should only have one entry in the list for that line. Write the method public List getlinesForWord(String word) that looks up a word and returns a list of lines in which it occurs. Write the method public void printIndexO the prints out each unique word that is stored in the Avl tree along with a list of line numbers in which that word appears. Finally, the main method in Problem2.java should create an instance of your AvlTree and uses it to indexes the words contained in a text file (provided to the program as a command line argument). Ignore case in the input text insert everything as lower case), and ignore all punctuation. When indexing has finished, the program should call the printIndex method to display a list of unique words in the text file and the line numbers in which that word occurs UnderFlowException class *Exception class for access in empty containers such as stacks, queues, and priority queues. *author Mark Allen Weiss public class UnderflowException extends RuntimeException

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

=+industrial action Under what circumstances can unions strike?

Answered: 1 week ago

Question

=+What forms of industrial action are common?

Answered: 1 week ago