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 by

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 UnderFLowException class, which is available here). Modify this file directly and add the following functionality: o Make sure the elements in the AvlTree 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 o Write the method public void indexWord(String word, int line) that adds an occurrence of the word word in line 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. o Write the method public List getLinesForWord String word) that looks up a word and returns a list of lines in which it occurs. o 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. * Cauthor 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 UnderFLowException class, which is available here). Modify this file directly and add the following functionality: o Make sure the elements in the AvlTree 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 o Write the method public void indexWord(String word, int line) that adds an occurrence of the word word in line 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. o Write the method public List getLinesForWord String word) that looks up a word and returns a list of lines in which it occurs. o 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. * Cauthor 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

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

3. Would you say that effective teamwork saved their lives?

Answered: 1 week ago