This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2012-10-14 13:26:36

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: A simple learning chatbot in Python

Gravitation wrote:

Molybdenum wrote:

Gravitation wrote:

And it's back up.

(sorry for the consecutive posts, I can't edit yet)

Excuse me for being stupid, but where is your website?

Gravi.tation.tk

The files are chat.php and chat.dat.

Is it just me, or do the tabs on the left do nothing?


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#52 2012-10-14 13:29:22

transparent
Scratcher
Registered: 2011-04-19
Posts: 1000+

Re: A simple learning chatbot in Python

I still can't connect to it. I've had trouble connecting with some .tk domains.


yes, yes i do.

Offline

 

#53 2012-10-14 13:30:26

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: A simple learning chatbot in Python

It could be a anti-virus thing  hmm


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#54 2012-10-14 13:35:17

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: A simple learning chatbot in Python

Molybdenum wrote:

Gravitation wrote:

Molybdenum wrote:


Excuse me for being stupid, but where is your website?

Gravi.tation.tk

The files are chat.php and chat.dat.

Is it just me, or do the tabs on the left do nothing?

They do nothing, I'm not done with the website yet; I have nothing to put on there.

transparent wrote:

I still can't connect to it. I've had trouble connecting with some .tk domains.

Hmm. Weird.  hmm

Offline

 

#55 2012-10-14 14:01:37

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: A simple learning chatbot in Python

Gravitation wrote:

blob8108 wrote:

This is still my favourite chatbot:

Code:

import random
messages = []
while 1:
    messages.append(raw_input("? "))
    print random.choice(messages)

tongue

tongue

I knew you would post here, since you're a Python programmer.  tongue

I found the thread eventually...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#56 2012-10-14 14:20:21

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: A simple learning chatbot in Python

I did make a learning chatbot once that automatically built a dictionary of inputs versus lists of possible responses as you talked to it. It would add your replies as possible responses to the last thing it said, if that makes sense. I wrote an interface for an anonymous chatroom and got it to learn from random strangers... It generated some very amusing chat logs  big_smile

The trick was to use fuzzy string comparison (called Levenshtein distance, if you're interested) when comparing the current input against the dictionary. It compared sentences, and then words, and then letters (exactly the same was 1.0, upper/lowercase of the same letter were set as 0.8 similar, for example, and so on).

It picks a random response from the input with the best match. Below a certain threshold (about 0.4, iirc) it just gives a random response.

So as a result, if it says "How are you?", and you say "Fine, thanks!" in reply, it will then respond to "how're you today" (or similar) with "Fine, thanks!".

So, there are my thoughts  tongue  I could post code if you're interested (:

Last edited by blob8108 (2012-10-14 14:21:07)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#57 2012-10-14 14:31:04

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: A simple learning chatbot in Python

blob8108 wrote:

I did make a learning chatbot once that automatically built a dictionary of inputs versus lists of possible responses as you talked to it. It would add your replies as possible responses to the last thing it said, if that makes sense. I wrote an interface for an anonymous chatroom and got it to learn from random strangers... It generated some very amusing chat logs  big_smile

The trick was to use fuzzy string comparison (called Levenshtein distance, if you're interested) when comparing the current input against the dictionary. It compared sentences, and then words, and then letters (exactly the same was 1.0, upper/lowercase of the same letter were set as 0.8 similar, for example, and so on).

It picks a random response from the input with the best match. Below a certain threshold (about 0.4, iirc) it just gives a random response.

So as a result, if it says "How are you?", and you say "Fine, thanks!" in reply, it will then respond to "how're you today" (or similar) with "Fine, thanks!".

So, there are my thoughts  tongue  I could post code if you're interested (:

Very interesting stuff! Can I see the code?

Offline

 

#58 2012-10-14 14:42:31

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: A simple learning chatbot in Python

Gravitation wrote:

blob8108 wrote:

I did make a learning chatbot once that automatically built a dictionary of inputs versus lists of possible responses as you talked to it. It would add your replies as possible responses to the last thing it said, if that makes sense. I wrote an interface for an anonymous chatroom and got it to learn from random strangers... It generated some very amusing chat logs  big_smile

The trick was to use fuzzy string comparison (called Levenshtein distance, if you're interested) when comparing the current input against the dictionary. It compared sentences, and then words, and then letters (exactly the same was 1.0, upper/lowercase of the same letter were set as 0.8 similar, for example, and so on).

It picks a random response from the input with the best match. Below a certain threshold (about 0.4, iirc) it just gives a random response.

So as a result, if it says "How are you?", and you say "Fine, thanks!" in reply, it will then respond to "how're you today" (or similar) with "Fine, thanks!".

So, there are my thoughts  tongue  I could post code if you're interested (:

Very interesting stuff! Can I see the code?

Hmm, fuzzy comparison. I need to know how to do that.


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#59 2012-10-14 15:51:01

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: A simple learning chatbot in Python

Molybdenum wrote:

Hmm, fuzzy comparison. I need to know how to do that.

I just found a Levenshtein distance algorithm on the internet...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#60 2012-10-15 13:49:42

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: A simple learning chatbot in Python

Gravitation wrote:

blob8108 wrote:

I did make a learning chatbot once ...
Very interesting stuff! Can I see the code?

Sure, I'll clean it up a bit and post it here.

In the meantime, here's a sample conversation, starting from a blank memory:

Code:

YOU: Hi!
BOT: Hi!
YOU: How are you?
BOT: How are you?
YOU: I'm alright, thanks. How are you?
BOT: I'm alright, thanks.
YOU: Good! Let's have a party.
BOT: Good!
YOU: Yes.
BOT: How are you?
YOU: Good, thanks!
BOT: Let's have a party.
YOU: Yes, let's!
BOT: Yes, let's!

tongue

(It gets better, honestly...)

Last edited by blob8108 (2012-10-15 13:50:13)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#61 2012-10-15 14:05:59

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: A simple learning chatbot in Python

blob8108 wrote:

Gravitation wrote:

blob8108 wrote:

I did make a learning chatbot once ...
Very interesting stuff! Can I see the code?

Sure, I'll clean it up a bit and post it here.

Here you go!

It's some of the messiest code I've ever written, by virtue of being the product of my procrastination for exams the summer before last...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#62 2012-10-15 14:22:10

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: A simple learning chatbot in Python

blob8108 wrote:

blob8108 wrote:

Gravitation wrote:

Sure, I'll clean it up a bit and post it here.

Here you go!

It's some of the messiest code I've ever written, by virtue of being the product of my procrastination for exams the summer before last...  tongue

Hrm. It immediately closes after it opens. Something about JSON.  hmm

Offline

 

#63 2012-10-15 14:32:08

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: A simple learning chatbot in Python

Gravitation wrote:

blob8108 wrote:

blob8108 wrote:


Sure, I'll clean it up a bit and post it here.

Here you go!

It's some of the messiest code I've ever written, by virtue of being the product of my procrastination for exams the summer before last...  tongue

Hrm. It immediately closes after it opens. Something about JSON.  hmm

Which Python are you using? Did you run it from terminal? You need to pass an argument telling it where to save its memory, like

Code:

python chatbot.py memory.json

Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#64 2012-10-15 14:36:34

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: A simple learning chatbot in Python

blob8108 wrote:

Gravitation wrote:

blob8108 wrote:


Here you go!

It's some of the messiest code I've ever written, by virtue of being the product of my procrastination for exams the summer before last...  tongue

Hrm. It immediately closes after it opens. Something about JSON.  hmm

Which Python are you using? Did you run it from terminal? You need to pass an argument telling it where to save its memory, like

Code:

python chatbot.py memory.json

Oh, okay. Thanks, it works now  big_smile

Excuse my stupidity, I have Windows  tongue

Offline

 

#65 2012-10-15 14:37:58

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: A simple learning chatbot in Python

Gravitation wrote:

Excuse my stupidity, I have Windows  tongue

It's okay, I'll forgive you — I'll pretend it's just Windows being stupid, and not you...  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#66 2012-10-15 14:42:57

Gravitation
New Scratcher
Registered: 2012-09-26
Posts: 500+

Re: A simple learning chatbot in Python

blob8108 wrote:

Gravitation wrote:

Excuse my stupidity, I have Windows  tongue

It's okay, I'll forgive you — I'll pretend it's just Windows being stupid, and not you...  tongue

Thanks.

But seriously, I'm new to programming (not Scratch, though); I have no idea how most of the stuff works.  tongue

Offline

 

Board footer