As usual, create a directory to hold today's files. All programs that you write today should be stored in this directory.
$ cd ~/cs120/labs $ mkdir lab29 $ cd lab29
All chat bot programs must have the same output format so that it is not possible to distinguish between bot and human based on format.
For example, the output of the program should look like:
> hello bot hello human > can you pass a Turing test? no, do you want to play chess?
python3 verify_bot.py
YOUR_BOT_FILE_NAME.py
. The client program will communicate with the server to determine who you will chat with and will connect you to the bot or person you will chat with.
python3 loebner_client.py YOUR_BOT_FILE_NAME.py
.
Note, YOUR_BOT_FILE_NAME.py is the name of your chat bot python
file.You are probably as reliant on spell checking as I am. It is a process that has evolved tremendously over the past couple of decades. Real spell checkers us a data structure known as a Tree to make retreiving of mispelled words incredibly efficient. However, if you ignore the efficiency, checking a word against a dictionary of words is fairly straight forward.
Create a file called spell_check_word.py
That will
allow a user to type in a word to get spell checked. Your program
will read in a dictionary of words that it knows are correctly
spelled. If the word the user typed in is in the dictionary file,
then output that the word is spelled correctly. If it is not in the
dictionary file, output that the word is not spelled correctly.
You can use our provided dictionary_file.in file in order to check spelling.
$ python3 spell_checker.py What do you want to spell check? helol helol is not spelled correctly $ python3 spell_checker.py What do you want to spell check? hello hello is spelled correctly
check_dictionary(word, file_name)
. The
function should take two string parameters: The word the uses
wishes to check the spelling of, and a string which is the
name of a text file representing the correctly spelled words.
It should return a boolean, True if the word is in the
dictionary file, and false otherwise.
The hamming distance between the two words is the number of characters that need to be flipped in order to make the words the same. Note that the hamming distance between two words is only defined when the strings are of the same length.
Using the notion of hamming distance, modify your above program so that it outputs a suggestion of what word the user meant to type. This will simply be the word from the dictionary that has the smallest hamming distance.