"The **Turing test**, originally called **the imitation game** by Alan Turing in 1950, is a test of a machine's ability to exhibit intelligent behaviour equivalent to, or indistinguishable from, that of a human."
"- Watch a great movie about Alan Turing and Enigma code: https://www.imdb.com/title/tt2084970/\n",
"- Food for thought: would an AI purposefully hide its superintelligence in fear of being destroyed? Maybe it is intentionally failing Turing test? (if you are interested in this topic, \"Philosophy of AI\" is the general field this question belongs to)\n"
"**Edit distance** is a way of quantifying how dissimilar two strings (e.g. words) are to one another by counting the minimum number of operations required to transform one string into the other. **Levenshtein distance** is the most common metric and often used interchangeably with edit distance."
"- computational biology/bioinformatics (comparing DNA sequences)\n",
"- correction of spelling mistakes or OCR errors\n",
"- approximate string matching, where the objective is to find matches for short strings in many longer texts, in situations where a small number of differences is to be expected (e.g. encryption).\n",
" print(\"Here are the name of movies I know directed by \" +input_name +\":\")\n",
" display(movie_names.reset_index(drop=True))\n",
"\n",
" #handle the misspelled director's name:\n",
" else:\n",
" \n",
"\n",
" distances = [nltk.edit_distance(input_name,director) for director in directors] #computing edit distance of the input name if not found in the list with all directors\n",
" \n",
"\n",
" guessed = directors[distances.index(min(distances))] #getting minimum distance director's name with the input\n",
" answer = input(\"Did you mean \"+ guessed+\"?(y/n))\") # asking feedback from the user if we found the correct name\n",
" if(answer.lower() in [\"yes\",\"y\"]):\n",
" movie_names = movies.loc[movies['director'] == guessed]['original_title'] # looking for movies from the director if the guess was correct\n",
" print(\"Here are the name of movies I know directed by \" +guessed +\":\")\n",
" display(movie_names.reset_index(drop=True))\n",
" elif(answer ==\"q\"):# checking if user already wants to exit program\n",
" quit = True\n",
" continue;\n",
" else:\n",
" print(\"I might not know this director! sorry\") # Giving up on first wrong guess!\n"
"<p style=\"color:green;\"><b>Type your response here<b><p>\n",
"\n",
"Jaccard distance does not consider the position of the characters in computing the distance, so if the characters all exist but they are in the wrong order Jaccard distance find the closest match , however since the Levenshtein distance only considers insert , delete and substitute as actions , if the characters are all in wrong positions the edit distance would be very high and not close to the match.\n",
"\n",
"\n",
"consider this pattern for example: Chyn DaLdiv\n",
"\n",
"``` distances = [nltk.jaccard_distance(set(input_name),set(director)) for director in directors] #computing edit distance of the input name if not found in the list with all directors ```"
"time = \"12:05 PM Tuesday, September 01, 2020 (GMT+2)\"\n",
"\n",
"groups = regex.match(\"(\\d{2}):(\\d{2})\",time)# \\d matches digit and using {} you can choose the number of repetitions for instance \\w{2-5} mins minimum 2 alphabetical characters and maximum 5 alphabetical characters\n",
"4- **Observe and Reflect** Please give an example of a pattern that can be considered by the regex correct in the example above (when extracting time) even though they are in fact not correct?\n"
"6- **CODE IT** In the following text from \"Alice in wonderland\" find where in text someone is quoted and their quote (as best as you can) by filling the regex in the match function.\n",
"\n",
" Note: make sure you use correct quotation characters"
"7- **CODE IT** The following code is supposed to extract hashtags from a tweet. Find all hashtags in the tweet using \"findHashtags\" regex and return them as a list.\n",
"If if complete the exercise above correctly, the following code will create 2 wordclouds of the hashtags used by Republicans and Democrates separately. Run the code below and wait."
" [r\"(.*) age?\",[\"I'm a computer program dude\\nSeriously you are asking me this?\",]],\\\n",
" [r\"what (.*) want ?\",[\"Make me an offer I can't refuse\",]],\\\n",
" [r\"how is weather in (.*)?\",[\"Weather in %1 is awesome like always\",\"Too hot man here in %1\",\"Too cold man here in %1\",\"Never even heard about %1\"]],\\\n",
" [r\"i work in (.*)?\", [\"%1 is an Amazing company, I have heard about it. But they are in huge loss these days.\",]],\\\n",
" [r\"(.*)raining in (.*)\", [\"No rain since last week here in %2\",\"Damn its raining too much here in %2\"]],\\\n",
" [r\"how (.*) health(.*)\",[\"I'm a computer program, so I'm always healthy \",]],\\\n",
" [r\"quit\",[\"BBye take care. See you soon :) \",\"It was nice talking to you. See you soon :)\"]]]\n",
" print(\"Hi, I'm Chatty and I chat alot ;)\\nPlease type lowercase English language to start a conversation. Type quit to leave \") #default message at the start \n",