Checking Speller
Open-source projects (whose source code is, by definition, open to anyone) are commonly stored on sites like GitHub, where other programmers can not only view the code but also open “issues” to report problems (or request features). Suppose, in fact, that @dmalan has recently pushed his implementation of Speller, in Python, to the GitHub repository at github.com/cs50/speller. But he’s already noticed some issues with his own code, per github.com/cs50/speller/issues?q=is%3Aissue+author%3Admalan+sort%3Acreated-asc+is%3Aclosed.
For each of the issues below, explain how resolve it in no more than three sentences, citing line numbers and proposing new lines of code as appropriate. Take care not to introduce any bugs!
- (2 points.) File is never closed in load function
- (2 points.) Checking words always takes linear time
If you’d like to download the repository’s code into your codespace, execute, e.g.:
wget https://github.com/cs50/speller/archive/refs/heads/main.zip
unzip main.zip
If you’d like to run the (buggy) code, execute, e.g.:
cd speller-main
python speller.py dictionaries/large texts/lalaland.txt