Tressy 2.0

Well, after a lot of work, the second version of my Python chat bot is in beta testing.

Her response file is still small, but thats why I need you.

Right now she is running on a test server here:

I have very limited bandwidth there, so though I want you to talk as you wish, please don’t just mess around.

Here is what she can do so far:

Responses are now saved in an .xml file. Accessing is now much faster. The files are similar to AIML, but with some improvements.

She can give multi responses for a single question.

A new fuzzy logic algorithm is now being used.

She can solve math problems, even word problems. Example: “15-3+4”, “What is ten minus three plus four?”
Note that she does not know the names of numbers over ten. “What is 15 minus three plus four?” should work, however.

She can solve simple leaner equations. x must be used as the var, and there can be only one. Example: “Solve x=2+2”.

You can now teach her correct responses. Simple use the #wrong command, followed by the correct response. Example:

You>“I like green.”
Tressy>“I don’t under stand.”
You>"#wrong Green is a very fine color."

Because the way my server is ran, changes will not take effect until I manually add them. This is because I have no way of checking who is talking to her. I will be adding IP logging soon, so she knows who she is talking to, and the last thing she said to them.

Please don’t have her curse, and use only responses that fit her personality. The responses you create are temporary, and I will ether add them to her main code, or remove them.

A log file is saved of everything you say, so I will know if a problem occurs, or if you abuse her.

The source will be released within the next month. If you really want/need it, I can work something out with you. It is easily scalable for using in a game, or what ever you wish.

Example use (subject to change):

#Import brain:
import brain

brain = brain.Brain("Sothh")

input = ""

while input != "exit":

    input = raw_input("> ")
    print brain.ProcessMessage(input) + "\n"

Enjoy, and start talking!

Very nice work! I tried it a bit and the answers are not bad.

I’m planning to do the same but with a 3D animation and speech recognition. Since I just started with this topic, it would be great if you have some links or tips about the algorithm you’re using.

Thanks and keep coding :slight_smile:



Here is a bit more in-depth version of how Tressy works:

I have a large library or responses stored in a .xml file. A sample of this file follows:








		<pattern>Good morning.</pattern>
		<pattern>Good night.</pattern>
		<pattern>Good afternoon.</pattern>

		<response>Though I do not experience time as human do, I will asume that it is, infact, good.</response>



Tressy parses this into a list, such as:

She searches your input against this list using a for loop. She compares the input against a pattern using Levenshtein distance and returns the percent match. Which ever input has the highest match is used, and if its under a 40% match, she tells you she does not understand. She takes the index of the highest match, and randomly selects one of the outputs.

There is a lot more that happens, but you will find it in the source that I will shortly be releasing.[/url]

Thanks, that’s interesting!
Since I’m working a lot on bioinformatics, I was thinking to try with Needleman-Wunsch or Smith-Waterman.

I definitely will have a look on your code :exclamation:


I will PM you a link to the source.

Hmm, this one doesn’t seem very friendly. Also, are you using a neural network, and if so, which library are you using for that?

I read your log. That was some rather unkind things you said. :wink:

She does not use a neural net. I have played around with some, but its much to hard processing text with them. Do you know of a good library.

She seems unfriendly becuase I thought it rather fun for her to act like its your fought if she messes up, and because she does not know much yet.

Your log will come is useful.

Please note that I will be allowing her to IP ban people for talking inapropeatly to her once she leaves Beta.

The only neural network library I’ve played with was GPL-licensed, so sorry, I have no suggestions in that aspect.
If you’re having trouble with processing text, though, maybe you could first convert words into a unique code per word (preferably clumping synonyms together). This could be done using a simple dictionary lookup or a neural network if it should be smarter. Then, you could utilise a neural network to translate sequences of these codes into behaviour.
That said, I’m not an expert at neural networks, and it’s in the middle of the night here, so take my suggestion with a grain of salt. :slight_smile:

Just a suggestion, but how about making it simply censor out those words in public logs, or even hiding public logs that contain words that you consider “inappropriate”? That way, you wouldn’t be enforcing a particular moral code onto your users while you would still avoid offending others.

The problem is getting the text into the neural network to start with.

Turning strings into neuron values is very hard.

The logs are not public. I just rather not have to program responses for “some” words, and I find it reasonable for her to simple not want to talk to people if they ignore her request not to use them. She in enforcing her moral code. :slight_smile:

Otherwise she appears stupid for not responding.

Give her another spin though, I update her data base quite often, so it won’t take long before she stops making the mistakes she made last time.

Just noticed a major bug with parsing. I am working to fix it ASAP.

That’s why I proposed translating words to a code, and inputting that into the neurons. In its simplest form, assigning a unique identifier to every word and using that as input instead of trying to teach it to interpret a binary representation of characters.

I understand your reasoning, but it seems kind of harsh to ban the IP address that the person in question is using, and I see no logical benefit whatsoever to do so.

I have done that, the library I used is just very slow, as its written in pure Python.

I also could not get it to work correctly.

I have updated the bot, to fix the error were she makes multi responses to the same statement.


She can now learn things as follows:

“What are green?”

“Sorry, I do not understand.”

“People are green.”

“Thanks for teaching me!”

“What are green?”


“What are people?”


…if I’m not mistaken, you’re using AIML right?

This might be relevant: … vironment/