Hi, I’m trying to make a chat bot, but I’m not sure how I would make the program interpret the users words, does anyone know how to make it?
@Prynok You could start by putting the most common words in a table as the key, with how you want to react to those words.
Sorry if I didn’t state it well in the original post, but I meant how can I decide what the user says?
Lets say the user types in “The cat is fat”
how could the program break it down into sectors, so I could do
if sentence == fat then
table.add(sometable,fat)
end
if sentence == the then
table.add(sometable, why)
end
And then save the contents of the table. Then when something new comes up you could ask what would you like the reply to be(In a way it doesn’t look like you’re asking), and then save it in the table too.
There are several open source chatbots - find one and translate the source code.
I’d start with Eliza.
Some people have spent their careers trying to achieve this. It is HARD! It may be easier to start with a small fixed set of words and get Codea to understand them.
So how can you break the sentences into words
@joaquin You would parse the sentence searching for a space. You could put each word into a table and then identify what each word means. To start, you’ll need a small table of words with what action you want to take for each word. It would have a limited vocabulary, but you can keep adding to it.
@joaquin Here’s some code that splits words.
function setup()
tab={}
str="Some people have spent their careers trying to achieve this. It is HARD! It may be easier to start with a small fixed set of words and get Codea to understand them. So how can you break the sentences into words."
for word in string.gmatch(str,"(%w*)[%.% %!]") do -- find each word
table.insert(tab,word) -- put each word into the table
end
print(table.concat(tab,"\
")) -- print the table
end
AIs are known to overwrite themselves. I suggest you to create a new text file, and respond with it.