Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Basic task: Object Oriented Programming Write a Java program that reads a text file and reports the tokens for each sentence reports the 2-character shingles

Basic task:

Object Oriented Programming image text in transcribed

Write a Java program that

reads a text file and

reports the tokens for each sentence

reports the 2-character shingles for each sentence

Command argument: the name of the input file Output to console in the required format

A token is simply a String that contains no spaces within it

tokens are separated by whitespace, but can include punctuation A 2-character shingle is simply a String that contains two consecutive characters.

They are called shingles because they must overlap, that is, the first character of the next shingle is the second character of the previous shingle.

For example, consider the String "banana split". The shingles for this string are:

'ba' 'an' 'na' 'an' 'na' 'a ' ' s' 'sp' 'pl' 'li' 'it'

Please note that this list include duplicates. It also includes the space character, which appears in the shingles 'a ' and ' s',

For our purposes, you should include all whitespace, punctuation, special characters, and numbers in our shingles, exactly as they appear. Also, you should not convert upper case letters to lower case, or vice versa.

Create a project in Eclipse

Type in the code for SentenceUtils.java and SentenceUtilsTest.java (templates are provided in the assignment), and add the required course header to each file

Copy or create a cats.txt file for use in testing your program

Output Format COP3330 Sentence Utility Program by [ your name or names ] from main() in SentenceUtilsTest Input file name: cats.txt Number of sentences: 3 Sentence 0 > The cat in the hat Tokens: 0: The 1:cat 2:in 3: the 4: hat from report() in SentenceUtils Shingles: Th 'he' 'e'c 'ca' 'at 't'i' 'in' 'n from main() in SentenceUtilsTest Sentence 1 > The cat sat on the mat from report() in SentenceUtils [ remaining output not shown COP3330 Object Oriented Programming 6

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

Students also viewed these Databases questions

Question

=+4 Develop and deliver the CCT program.

Answered: 1 week ago