Question: Workshop # 1 : Dictionary In this workshop, you will create a dictionary application that will allow the client to find the definition ( s

Workshop #1: Dictionary
In this workshop, you will create a dictionary application that will allow the
client to find the definition(s) of a word in English. The application will load
the list of words and their definitions from a text file; although the provided
file is for English language (a version of The Gutenberg Webster's Unabridged
Dictionary in csv format), the application should work with dictionary in other
languages.
Compiling and Testing Your Program
All your code should be compiled using this command on matrix:
/usr/local/gcc/10.2.0/bin/g++-Wall -std=c++17-g -o ws file1.cpp file2.cpp ...
-Wall: compiler will report all warnings
-std=c++17 : the code will be compiled using the C++17 standard
-g : the executable file will contain debugging symbols, allowing valgrind
to create better reports
-o ws: the compiled application will be named ws
After compiling and testing your code, run your program as following to check
for possible memory leaks (assuming your executable name is ws):
valgrind --show-error-list=yes --leak-check=full --show-leak-kinds=all --track-origins=yes
--show-error-list=yes: show the list of detected errors
--leak-check=full: check for all types of memory problems
--show-leak-kinds=all: show all types of memory leaks identified (en-
abled by the previous flag)
--track-origins=yes: tracks the origin of uninitialized values (g++ must
use -g flag for compilation, so the information displayed here is meaning-
ful).
To check the output, use a program that can compare text files. Search online
for such a program for your platform, or use diff available on matrix.
Dictionary
This application loads a set of words from a file in csv format (comma separated
values), stores them in memory, and performs some operations on them. The
application will also measure the duration of certain operations, allowing the
user to compare their performance. The time it takes to complete an operation
will depend on the machine where the application is running; however, the rela-
tive difference in performance between various operation should hold regardless
of the underlying hardware.
The input file will contain a large set of records; each record is stored on a single
line in the format:
word, pos, definition
Where:
word is the word being defined (might contain spaces).
pos is the part of speech.
definition is the definition of the word.
Put all the global variables, global functions/operator overloads, and types in-
side the seneca namespace.
tester_1 Module (supplied)
Do not modify this module! Study the code supplied and make sure you
understand it.
settings Module
The settings will contain functionality regarding configuration of the applica-
tion. Design and code a structure named Settings; in the header, declare a
global variable of this type named g_settings and define it in the implementa-
tion file.
For simplicity reasons, this type will contain only public data-members and no
member-functions.
Public Members
m_show_all as a Boolean attribute; when true, if a word has multiple
definitions, all definitions should be printed on screen, otherwise only the
first definition should be shown (default false).
m_verbose as a Boolean attribute; when true, print to screen the part-of-
speech of a word if it exists (default false).
m_time_units as a std::string attribute; stores the time units to
be used when printing duration of various operations. Possible values
are seconds, milliseconds, microseconds, nanoseconds (default
nanoseconds).
event Module
Design and code a class named Event that stores information about a single
event that happened during the execution of the program. At minimum, this
class should store the name of the event (as a string) and its duration (as an
object of type std: : chrono: :nanoseconds); add any other private members
that your design requires.
Public Members
a default constructor
Friend Helpers
operator: print to screen all the events stored in the logger in the
format:
EVENT
this class should store the address of the array; add any other private members
that your design requires.
Public Members
default constructor
Dictionary(const char* filename): loads from the file specified as pa-
rameter the collection of words, allocate enough memory (but no more)
for the array to store the data, and then load all the words into the array.
If the file cannot be open, this function puts the current instance in an
empty state.
When loading the pos field from the file, only the following values are
considered valid:
Any other value found (or no value whatsoever) is considered to be
PartOfSpeech: :Unknown.
void searchWord(const char* word): searches in the collection of
words the one specified as a parameter. If the word is found, print the
definitions in the following format:
If in the global settings m_verbose is false or the word has
PartOfSpeech: :Unknown, then (PART_OF_SPEECH) is not printed.
If the word
Workshop # 1 : Dictionary In this workshop, you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!