• In this assignment, you will write a program that sorts text files formatted like the file assignment25.txt, attached below.
• In the file: English and Japanese versions of the same word are separated by a tab (‘\t’); one word per-line.
• You will be sorting by the English words. In sorting them, disregard case – a capital letter is considered the same as the corresponding lowercase letter. Also, disregard anything enclosed in brackets at the beginning of a line, anything enclosed in parentheses at the beginning of a line, and disregard spaces at the beginning of a line (see Instructions).
• You may use the attached starter code for your assignment: A25StarterCode.cpp
• Download it to your computer and change the name of the file.
• Change the comments as appropriate.
Instructions:
• Use commandline input to input the filename.
• For example, the UNIX command is: ./a.out assignment25.txt
• In your program, argv[1] will contain the filename.
• Use the ifstream class for file input.
• Read one line at a time from the input file.
• Break the line into three parts: the original English part,the original Japanese part, and the sort field.
• The English and Japanese words are divided by a tab (“\t”).
• To split the English and Japanese parts, find the character position of the tab.
• Take a substring of the first part up to the tab for the English part
• Take a substring of the second part of each line for the Japanese part.
• Store these in two separate variables.
• Store the sort field in a third variable.
• The sort field is equivalent to the English part with a few changes:
• Change all of the capitalized English characters to lowercase letters.
• Remove any characters enclosed in brackets in front of any words.
• Remove any characters enclosed in parentheses in front of any words.
• Remove the space in front of any words.
• Define a class Entry which has three strings as data members: the English, the Japanese, and the sort field.
• You need a default constructor (a constructor with no parameters) for Entry.
• You need three set functions and three get functions for the three data members (strings english, japanese, and sortfield).
• Overload the Entry “less than” operator: operator<
• This will be used to sort Entry objects.
• The less than operator should compare the sortfield of two Entry objects.
• The first line of the operator<() function definition should be:
bool operator< (const Entry e) const{
• The code inside the function definition should be: If the sortfield of this object is less than the sortfield of the parameter, then return true. Otherwise, return false.
• Make a vector of Entry objects.
• Read the data from the file one line at a time, break the line into three parts as described above, and store the data for each line in an Entry object.
• Store each Entry object in the vector.
• Sort the vector of Entry objects.
• Display the English and Japanese parts of the sorted Entry objects to the screen.
• The text in the output should be the same as the text in the input file, but it will be sorted in the English word order and aligned in two columns.
• The lines in the output should form two columns, with the first letter of each word lining up with all the other words.
• To display Entry objects, you can write a friend function to overload operator<< (so you can use cout), or you may use the get() functions to access the English and Japanese words.
• Use the field width and left justification to make columns.
• See the example output below for details.
Example:
./a.out assignment25.txt
A.M. gozen
about (time) -koro -goro
about ~ [Not used for time.] -kurai -gurai
absent (o)yasumi
(be) absent (from ~) (-o) yasumimasu
address juusho
after (not time) (-no) ato de
after (time) -sugi
again mata
airplane hikooki
all right daijoobu
already moo (+aff.)
always itsumo
am desu
America amerika
amuse [not used for sports & music] asobimasu
(Noun1) and (Noun2), etc. (N1) ya (N2)
and [only at beginning of sentence] soshite
and [used between two nouns] to
And then sorekara
(not) anything nanimo+Neg.
(not to) anywhere dokoemo+Neg.
April shigatsu
are desu
art bijutsu
at (location) [with existence verb] ni
at (place) [with action verb] de
[with action verb]at (specific time) (specific time) ni
[with existence verb](not) at all zenzen+Neg.
August hachigatsu
aunt obasan
autumn aki
bad warui
bag baggu
ball point pen boorupen
balloon fuusen
baseball yakyuu
basketball basuketto(booru)
bathroom (o)toire, (o)tearai
beach umi
beard hige
beautiful utsukushii
because (reason) kara, (result)
bed beddo
before mae
before (not time) (-no) mae ni
before (time) -mae -
begin hajimemasu
Besides [at beginning of a sentence] soreni
bicycle jitensha
big ookii
bird tori
birthday (o)tanjoobi
(is) black kuroi
black kuro
(is) blue aoi
blue ao
boat fune
body karada
book hon
bookstore honya
boring tsumaranai
born in (month) -gatsu umare -
bow rei
bowlful -pai -
box lunch bentoo
boy otoko no ko
bread pan
(a) break yasumijikan
breakfast asagohan
(is) brown chairoi
brown chairo
building tatemono
bus basu
busy isogashii
But [at beginning of a sentence.] demo
but [less formal than demo] (sentence 1) ga, (sentence 2)
buy kaimasu
by (tool) (tool) de
by (transportation facility) (transportation) de
cafeteria kafeteria
camera kamera
camp kyanpu
can do well tokui
can hear kikoemasu
can see miemasu
candy ame, kyandii
cannot hear kikoemasen
cannot see miemasen
cap booshi
car kuruma, jidoosha
(playing) cards toranpu
cat neko
cent(s) -sento -
chair isu
cheap yasui
child kodomo
China chuugoku
Chinese language chuugokugo
chocolate chokoreeto
chopsticks (o) hashi (
class jugyoo, kurasu
classroom kyooshitsu
clean kirei
clock tokei
(to) close shimemasu
close, near chikai
(Please) close. shimete kudasai
cockroach gokiburi
coffee koohii
coffee shop kissaten
cola koora
(a) cold kaze
(is) cold samui
(is) cold (to the touch) tsumetai
college daigaku
college student daigakusei
color iro
come kimasu
company kaisha
company employee kaishain
computer konpyuutaa
concert konsaato
Congratulations. omedetoo gozaimasu.
cool [temperature] suzushii
cousin itoko
cup koppu
cupful -pai -
cute kawaii
dance dansu