Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

part c We want to calculate all kinds of data related to texts. To do this, given any alphabetic text ( say, book or article

part c

We want to calculate all kinds of data related to texts. To do this, given any alphabetic text (say, book or article), we must create a data structure that stores the words that appear in it. The number of words in the text, the number of different words in the text, the most common word, the number of words that begin with a certain letter (say 'A').

To do this we define a class that represents the group of words in the text. There is no need to keep the order of the words as they appear in the text.

The class will represent the group of words in the most efficient manner - a list sorted in order of dictionaries.

You must use a class called Node that represents one node (a link) in the list, and a class called TextList that represents the entire list - a list.

Part A - class Node

The Node class will contain the following two private properties:

1. String word

2. Node next

You must write the constructors and methods required for use in the Node class as taught in the course.

The class names in the class will be:

getNext(), getWord(), setNext(Node next), setWord(String word)

Part B - class TextList

You must write the TextList class definition: it has only one attribute - the top of the list.

The TextList class will contain only one constructor - the empty constructor that initializes an empty list.

In addition, write to the class with the following methods, in the most efficient way possible! public void addToData (String word)

Which accepts a word that is read from the text and adds it to the data structure. It can be assumed that the word parameter contains a valid word with letters only. Remember that you have to keep the list sorted in order of dictionaries and therefore put it in the appropriate place. You can use the String compareTo method of string comparison.

public void parseTextIntoList (String text)

Which accepts as a parameter a string that represents text (that is, only words with a single space between each word) and adds the words to the list (each word separately and in its dictionaries). You can assume that the input is valid, meaning only words with lowercase letters, no punctuation or other marks, and there is a single space between each word. Use the code you've already written and do not duplicate code.

public int howManyWords ()

returns the number of words in the text. Write this as a recursive method.

public int howManyDifferentWords ()

returns the number of different words in the text. (Hint: the list is sorted).

public int howManyStarting (char letter)

takes a character and returns the number of words that begins with this character.

public String mostFrequentWord ()

returns the most occurring word in the text.(Hint: the list is sorted)

public String toString()

Passes the list to a string, between each word will be a single space. Note that since the words are entered in a sorted order, the order received here will be different from the order in which the words were inserted!

public void addToList(TextList other)

A method that adds all of the words in the list received as a parameter to the current list. It can be assumed that the list received is also sorted. And that the list is legal (contains words according to the known rules). Do not use the addToData method. The numbered lists must already be merged into one sorted list as in the merge filter.

Part C - class WordProcessor

Write a class WordProcessor that contains a GUI with text field to enter the text and a bottom for each method.

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions