ElfScript

  • 10 Replies
  • 8459 Views
*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6860
  • Mostly Harmless
ElfScript
« on: September 10, 2016, 09:03:39 pm »
So ElfScript is something I made up to make chatbots. It's inspired a lot by AIML but does things differently. It has fuzzy pattern matching for example that took me a while to get good results from. So it can get the gist of something even if the input is not exactly something it knows.

I haven't done any programming since April and I wondered what the heck I had done. It doesn't take long to go rusty.

The thought behind some of ElfScript is that it's as compact as possible. So say you have <pattern> in AIML, in ElfScript something similar is just i: so it's easier to type. I noticed ChatScript uses short commands like this too. Great minds think alike ! No I don't think my mind is as smart as Bruce's  ;)

The other thing about ES is that it can use some PHP in it's patterns - this is pretty useful for string handling. And it has custom functions, like building and adding to arrays to keep track of things. Or setting user specific variables and things like that. And you can mark fields in a similar way to AIML's topics. These fields can also depend on variables that you might set. And I've done a lot of work on conditional statements too. So in short; there's quite a few ways to handle the way a conversation might flow.

The way I designed it to avoid it getting taught garbage is it only learns per user. So if someone teaches it a lot of rubbish only they see it. It would be up to the botmaster if he/she wanted to learn public things.

I've been playing with simple learning. I figured why spend hours typing in patterns when you can just tell it things and it should learn them. If you had a microphone you could easily rattle a lot of stuff off without touching a keyboard.

It has some basic knowledge too supplied by online services like Wordnik for words and Wikidata for people and things.

So this is just a sample of the early point I am at. Here's a short chat.

Quote

Elf: Hello there.

Freddy: Hi

Elf: Greetings.

Freddy: My name is Freddy

Elf: Okay your name is Freddy.

Freddy: What is my name ?

Elf: It is Freddy.

Freddy: What fishes do you know ?

Elf: I don't know any, perhaps you can teach me some.

Freddy: A roach is a fish

Elf: Okay I will learn roach is a fish.

Freddy: A Pike is a fish.

Elf: Okay I will learn Pike is a fish.

Freddy: A Roach is a fish

Elf: I already know Roach is a fish.

Freddy: A carp is a fish

Elf: Okay I will learn carp is a fish.

Freddy: what fishes do you know ?

Elf: I know roach, Pike and  carp.

Freddy: forget Pike is a fish

Elf: I removed Pike from fish.

Freddy: A pike is a fish

Elf: Okay I will learn pike is a fish.

Freddy: what fishes do you know ?

Elf: I know roach, carp and  pike.

Freddy: what is a carp

Elf: Carp is a fish.

Freddy: Are pike a fish ?

Elf: Yes I know that one is a fish.

Freddy: Are cats a fish ?

Elf: I don't know it as a fish.

Freddy: Who is Donald Trump ?

Elf: Donald Trump is an American business magnate, television personality, author and politician.

Freddy: What is a cat ?

Elf: Cat ? An enthusiast or player of jazz.

Freddy: Thanks

What do you think ? Do you think I achieved something if I told you that to do that takes about 45 lines of ElfScript ?

« Last Edit: September 10, 2016, 09:34:08 pm by Freddy »

*

Korrelan

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1454
  • Look into my eyes! WOAH!
    • YouTube
Re: ElfScript
« Reply #1 on: September 10, 2016, 10:00:38 pm »
Looking very good, you have obviously given it a lot of thought and time.

I look forward to seeing the systems progression.

Chat bots are really growing on me.

:)
It thunk... therefore it is!...    /    Project Page    /    KorrTecx Website

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6860
  • Mostly Harmless
Re: ElfScript
« Reply #2 on: September 11, 2016, 01:20:03 am »
Thanks  :)

It's a fun exercise, I like programming in PHP.

It's a good way to learn new tricks too.

Clearly I need to be a bit more creative with my sentences, but at this stage it's just the bones I am working on.

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: ElfScript
« Reply #3 on: September 11, 2016, 03:27:22 pm »
Freddy, you never cease to amaze me with your unleashed creativity! I'm impressed...and with only 45 lines of ElfScript!
That was actually a very great exchange. Imagine what else you can code inside the script.

Does it have a provision for Wild Cards like *  ?
How are Triggers Handled or marked?

Is it capable of saving a log file of the conversation?

Could it be "taught" by feeding it info from say, a text file or other sources?

Keep up your experiments! O0
In the world of AI, it's the thought that counts!

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6860
  • Mostly Harmless
Re: ElfScript
« Reply #4 on: September 11, 2016, 05:31:15 pm »
Thanks Art. It's a start :)

Actually I had spent a while on this but kept quiet as I've got a lot of ideas to try out still.

I've resisted laying out any script because it is liable to change, but I can give you some examples to your questions.

Yes it has wildcards. I use % for the wildcard instead of *. This is because % is very useful in SQL queries as that's it's wild card. So I'm being a little economical by using it as my wildcard as the patterns are stored in a MySQL database. The fuzzy pattern matching takes it up a notch, but would be difficult to describe briefly here.

Here's an example of simple in out.

Code
i: i like to eat cake;
o: I'm not a fan myself;

That's it for a basic pattern.

If you wanted to match different inputs to the same output you just do this :

Code
i: i am a boy||i am male||i am a man;
o: Okay Mr !;

You don't need to write out each input/output pairing or do a lot of recursion. The whole idea is to reduce typing to a minimum. Similarly you can do this with the output, to pick a random response from one input...

Code
i: pick a random colour;
o: I choose magenta||I think black||How about cyan ?;

Quote
How are Triggers Handled or marked?

For triggers I use a format like PHP, but I use my own commands - so it's a bit like a wrapper around parts of PHP. My variables are prefixed with a $ like PHP too. So to test a variable you do something like this :

Code
i: is my name freddy;
c: ($username == "Freddy")
o: Yes !;
e:
o: No !;

Where c: means condition. So it checks if the variable $username is set to "Freddy". If it is, you get the output (o:) of Yes ! The e: is an else statement. This is a simple example, you can nest them and do other things like query an array of variables too.

And something I have called fields adds another level so that you can mark out a whole bunch of patterns that only apply in given situations - controlled by variables. Like AIML's topics but a little different and I hope more flexible.

Quote
Does it have a provision for Wild Cards like *  ?

Yup. Of course you would want to set that $username variable so you use the set (s:) command...

Code
i: my name is %;
o: Hello %1 pleased to meet you;
s: $username = %1;

The %1 is a quick way to refer to whatever wildcards you need. Like AIML has the <star index="1" /> or something like that, just shorter. So if there was a second wildcard you would get it with %2.

You can do other things with wildcards too like pluralise them correctly, turn them into variables and other little tricks. And like I mentioned you have access to a number of PHP commands to fiddle with it too.

Quote
Is it capable of saving a log file of the conversation?

I've got basic log files working just the other day as it happens, so I could show you guys what I had. The chat I posted came from a log file. I do plan to do much more with the log file for the use of the botmaster too.

Quote
Could it be "taught" by feeding it info from say, a text file or other sources?

Not so far, I don't rule anything out. But that kind of thing I think is quite an undertaking by itself. I think I would look around to see what's been done and then see if I can somehow use it to make patterns. However if text is set out in an organised way then it's a lot easier to parse. I've certainly scanned quiz questions and answers into it so far so I didn't have to type them all in. But if you want to take a book about gerbils and get some good information out of it, then so far I don't have anything.
« Last Edit: September 11, 2016, 11:14:50 pm by Freddy »

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: ElfScript
« Reply #5 on: September 13, 2016, 01:13:40 am »
Thanks for the explanation and examples. Nicely done. Looking forward to seeing / reading more progress as it unfolds with your experimental bot.

Oddly enough, your format reminded me a lot of RiveScript, if you've ever looked at it in depth.

It can handle multiple Triggers, wildcards and all sorts of input / output scenarios. The format is far easier than AIML scripting with categories, tags, objects, etc.

You, however, might just be onto something equally as interesting and engaging. Keep us posted! O0
In the world of AI, it's the thought that counts!

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6860
  • Mostly Harmless
Re: ElfScript
« Reply #6 on: September 13, 2016, 05:24:22 pm »
No problem :)

I knew about RiveScript, I think the chap behind it is Noah from Chatbots.org ? I only glanced at it a long while back but have never used it or know what it is capable of.

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: ElfScript
« Reply #7 on: September 13, 2016, 07:19:44 pm »
I created a chatbot with RiveScript and have been fine-tuning it for the past two or so years. I'm even using a very modified set of Topic Categories from an AIML set but with foreign language, swear words, slang, net-speak, <garbage> etc., removed. It is an English only bot, for now.

I only test it locally, on my desktop computer rather than put it in the "wild" just yet. It is quite capable and rather easy to grasp. Noah did an excellent job of providing documentation and a tutorial for new comers.

If I could only write a routine for it to "learn / remember" from conversations. Perhaps in time....

Here's an example of one of my rs files, similar to a Plug-in if you will. I can ask my bot to "Tell me something", such as a funny or ironic twist, a bit of trivia, etc. The one I use actually contains a great deal of these but this is an example of how it processes the initial user query.
#######################################

//  free software 2016

//  this file is open source code.
//  complies with RiveScript 2.0 Specs.

//  created by Art - last modified 07/29/2016

+ (tell me something|tell another|tell another one|tell another something|tell me another something)

<random>
- Do fish ever sneeze?
- Can sour cream go bad?
- What is the speed of dark?
- Why do clocks run clockwise?
- Why do doughnuts have holes?
- What do you call a male ladybug?
- Is there another word for synonym?
</random>

##################################

The botmaster / creator can construct any number of .,.rs files and as long as they reside in the same Directory / Folder as the main program, the bot can call from / use them as needed.

It can even play a somewhat shortened of a Text Adventure like the old ZORK or Adventure games.

I did another for my grandkids on the States & Capitals which works quite nicely.

It's worth checking out for any aspiring bot creators out there.

I'm still anxious to see Freddy's Chatbot in action. (is it going to be that cute red head, Tyler like the 3D character you created a while back?). I still have a pretty good memory. O0
In the world of AI, it's the thought that counts!

*

8pla.net

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1307
  • TV News. Pub. UAL (PhD). Robitron Mod. LPC Judge.
    • 8pla.net
Re: ElfScript
« Reply #8 on: January 14, 2017, 05:50:52 pm »
"Do you think I achieved something if I told you that to do that takes about 45 lines of ElfScript ?"

Yes.  That would be an achievement, at 45 thousand lines of compiled code, I think.
My Very Enormous Monster Just Stopped Using Nine

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6860
  • Mostly Harmless
Re: ElfScript
« Reply #9 on: January 14, 2017, 06:02:15 pm »
Thanks, that means a lot coming from an expert :)

I realised I can now answer Art's question :

Quote
I'm still anxious to see Freddy's Chatbot in action. (is it going to be that cute red head, Tyler like the 3D character you created a while back?). I still have a pretty good memory.

http://aidreams.co.uk/forum/index.php?topic=6913.msg45330

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Trusty Member
  • **********************
  • Colossus
  • *
  • 5865
Re: ElfScript
« Reply #10 on: January 14, 2017, 08:56:24 pm »
Yes, it appears that you have. I've always liked Jess and is seems that you do as well! O0
In the world of AI, it's the thought that counts!

 


LLaMA2 Meta's chatbot released
by spydaz (AI News )
August 24, 2024, 02:58:36 pm
ollama and llama3
by spydaz (AI News )
August 24, 2024, 02:55:13 pm
AI controlled F-16, for real!
by frankinstien (AI News )
June 15, 2024, 05:40:28 am
Open AI GPT-4o - audio, vision, text combined reasoning
by MikeB (AI News )
May 14, 2024, 05:46:48 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 31, 2024, 01:00:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am

Users Online

293 Guests, 0 Users

Most Online Today: 317. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles