Menu

[Solved] 1 Introduction Assignment Re Going Create Word Index Utility Java Utility Following O Read Q37259062

Need help with the following assignment in Java:

1 Introduction In this assignment, youre going to create a word index utility in Java. This utility will do the following: o

fun test 9 test 10 hello 11 goodbye 12 Collecting this, we have the following index information: hello 1,11 this 2,6 is 3,7 t

2.1 Required Classes Youre required to implement the following three classes LocationList This is a simple linked list of in

2.2 Class Details 2.2.1 LocationList constructor: takes no arguments, does whatever initialization you need methods: void add

1 Introduction In this assignment, you’re going to create a word index utility in Java. This utility will do the following: o read text from stdin (ignoring anything that’s not whitespace or a letter) and break it into tokens (called “words” even if they’re not really words i the usual sense), and convert each word to lowercase; . keep count of the location (starting from 1) of each word in the input stream: » build an index of each word, identifying all the locations in which it occurs; anc o print the index, with the words alphabetically-sorted. 1.1 Sample Behavior For example, if the input text consists of the following: Hello, this is a test. This is FUN!!! Test (test) hello Good_bye then the words and their locations are: hello 1 this 2 Is 3 test 5 this 6 1s fun test 9 test 10 hello 11 goodbye 12 Collecting this, we have the following index information: hello 1,11 this 2,6 is 3,7 test 5,9,10 fun 8 goodbye 12 so the sorted output would be: a 4 fun 8 goodbye 12 hello 1,11 is 3,7 test 5,9,10 this 2,6 2 Implementation Details Internally, your index is going to be a linked list of linked lists. The main list will contain the words, which will always be sorted. Each node will (as usual) contain a piece of data (the word) and a pointer to the next node; but additionally, each nodew also contain a pointer to a linked list of locations (integers). We’ll draw some pictures in class… 2.1 Required Classes You’re required to implement the following three classes LocationList This is a simple linked list of integers. Each word will be associated with a LocationList, which will be a list of all the locations where this word occurs. WordList This is a separate linked list of words (Strings) Each node will have three pieces: 1. the word 2. a LocationList, containing all the locations where this word occurs in the input; and 3. a pointer to the next node in the WordList. IndexUtility This is the class your main program would construct and use. It has a single method: buildlndex() which reads from stdin and returns a WordList containing the built index 2.2 Class Details 2.2.1 LocationList constructor: takes no arguments, does whatever initialization you need methods: void addToEnd(int data); add a new node (containing the given data) to the end of the LocationList 2.2.2WordList constructor: takes no arguments, does whatever initialization you need methods: . void addWord(String word, int location); either adds a new node (in sorted order), or appends a new location to the LocationList associated with the word o void print; traverses the list, and prints the (sorted) output: one word per line, followed by a space-separated list of locations (in increasing order) 2.2.3 IndexUtility constructor: takes no arguments methods: o buildIndex() reads stdin, builds a WordList, and returns that WordList Show transcribed image text 1 Introduction In this assignment, you’re going to create a word index utility in Java. This utility will do the following: o read text from stdin (ignoring anything that’s not whitespace or a letter) and break it into tokens (called “words” even if they’re not really words i the usual sense), and convert each word to lowercase; . keep count of the location (starting from 1) of each word in the input stream: » build an index of each word, identifying all the locations in which it occurs; anc o print the index, with the words alphabetically-sorted. 1.1 Sample Behavior For example, if the input text consists of the following: Hello, this is a test. This is FUN!!! Test (test) hello Good_bye then the words and their locations are: hello 1 this 2 Is 3 test 5 this 6 1s
fun test 9 test 10 hello 11 goodbye 12 Collecting this, we have the following index information: hello 1,11 this 2,6 is 3,7 test 5,9,10 fun 8 goodbye 12 so the sorted output would be: a 4 fun 8 goodbye 12 hello 1,11 is 3,7 test 5,9,10 this 2,6 2 Implementation Details Internally, your index is going to be a linked list of linked lists. The main list will contain the words, which will always be sorted. Each node will (as usual) contain a piece of data (the word) and a pointer to the next node; but additionally, each nodew also contain a pointer to a linked list of locations (integers). We’ll draw some pictures in class…
2.1 Required Classes You’re required to implement the following three classes LocationList This is a simple linked list of integers. Each word will be associated with a LocationList, which will be a list of all the locations where this word occurs. WordList This is a separate linked list of words (Strings) Each node will have three pieces: 1. the word 2. a LocationList, containing all the locations where this word occurs in the input; and 3. a pointer to the next node in the WordList. IndexUtility This is the class your main program would construct and use. It has a single method: buildlndex() which reads from stdin and returns a WordList containing the built index
2.2 Class Details 2.2.1 LocationList constructor: takes no arguments, does whatever initialization you need methods: void addToEnd(int data); add a new node (containing the given data) to the end of the LocationList 2.2.2WordList constructor: takes no arguments, does whatever initialization you need methods: . void addWord(String word, int location); either adds a new node (in sorted order), or appends a new location to the LocationList associated with the word o void print; traverses the list, and prints the (sorted) output: one word per line, followed by a space-separated list of locations (in increasing order) 2.2.3 IndexUtility constructor: takes no arguments methods: o buildIndex() reads stdin, builds a WordList, and returns that WordList

Expert Answer


Answer to 1 Introduction In this assignment, you’re going to create a word index utility in Java. This utility will do the followi… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *