Making our Chatbot Smarter - (using - specialFolderPath, Repeat For Each, Exit Repeat) We can make our chatbot smarter by adding more words and responses. We do that by adding more code. How many words do we need to have a smart chatbot? Right now, our chatbot has the intelligence of a 1 year old. To make it smart, we have to add a LOT OF WORDS. (see below). That is one heck of a lot of coding to do. A 6 year old knows 20,000 words ! Do we have to add 20,000 else-if's and code? How can we work smarter and make our job easier? We can use a list of words and responses and work from that. By putting our words and responses in a list or table or spreadsheet, we can add intelligence without having to add more code. We just write a small chunk of code to use that list. Exercise: (highly recommended if you want to understand this) Download and Try Animal Wizard - Look at the code. We are going to do the same to our Chatbot Changing Our Chatbot to Use a List/Table/Spreadsheet We are now going to add the same ideas to our chatbots. You can add the code to your current chatbot or start anew with the chatbot below. In Excel Spreadsheet: 1. Create a file for your new keywords and responses. ( I am going to use a Excel spread sheet to start with) The first column will be the words, the 2nd column will be the responses When done, save it as a tab-delimited "txt" file Name it and Save it: A "tab" will separate the 2 items - the "Word" and the "Response" (as seen in LiveCode and Notepad). That is how we can separate the columns and tell the WORD from the RESPONSE 2. Change the code in your program to read in the file of words/responses into a variable (myList) In the Card Script Add the global myList to the top of the card script e.g. (old code is black, your new code is red )
Add this to the beginning of the "openCard" handler (It opens the file (your list of words and responses, and puts it into the variable "myList")
e.g. (old code is black, your new code is red )
2. Add the code to search thru your list at the beginning of "getResponse" e.g. (old code is black, your new code is red )
Add another end if at the end of your searches e.g. (old code is black, your new code is red )
add a new function to search your list of words - "findWordInList" in between any other functions or handlers remember - In our file, we have the word - (a tab) -then the response e.g. (old code is black, your new code is red ) ...
... |

