Written Questions
To round out our assignment, we'll use our HashSet
class template as an actual dictionary of English words.
We've provided a source file, minispell.cpp
, which uses HashSet<std::string>
to provide a proof-of-concept for a rudimentary spelling checker. It's basically the same program you saw in Homework 6, but with some additional options to control insertion style.
Let's Go!
Build minispell
Run
make clean
make OPTFLAGS="-O3 -flto" minispell
Run minispell
If you run the program with the --help
argument, it will produce a usage message like
> ./minispell --help
Usage: ./minispell [options] [file-to-check ...]
Options:
-h, --help Print this message and exit.
-f, --file-order Insert words in the order they appear (default).
-r, --random-order Insert words in random order, by shuffling the input.
-b, --num-buckets Size of the hash table to use.
-l, --load-factor Max load factor to use.
-n, --num-dict-words Number of words to read from the dictionary.
-m, --num-check-words Number of words to check for spelling.
-d, --dict-file Use a different dictionary file.
-p, --print-dict Print the dictionary after insertion.
Default dictionary file: ../../data/smalldict.words
Default file to check: ../../data/ispell.words
If you run it without any arguments, you should see output similar to
Reading words from /home/student/data/smalldict.words... done!
Inserting into dictionary (in order read)... done!
- insertion took 0.000112333 seconds
- 341 words in 512 buckets
- 7 expansions, load factor 0.666016, 93 collisions, longest run 4
Reading words from /home/student/data/ispell.words... done!
Looking up these words in the dictionary... done!
- looking up took 0.00124775 seconds
- 34831 words read, 325 in dictionary
Exploration
Explore some of the other options to the program by doing some other runs. Also, feel free to run the program multiple times to see if/when the program output varies.
Questions
On Gradescope, you'll find some questions asking you to run this program and think about the results.
(When logged in, completion status appears here.)