keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
348 stars 138 forks source link

A new language for AIML #233

Closed keiffster closed 4 years ago

keiffster commented 4 years ago

I've been playing round with defining a new language for AIML, during a recent project which required writing a lot of new and complex AIML the use of XML started to become the inhibitor of rapid development.

This is the bare bones of the language, it shows the basics of the grammar and how simple pattern matches are made up. Ive started work on a parser which converts to AIML, along with an AIML to the new langauge ( as yet unnamed, but possible AIPL - AI Programming Langauge ) converter

The intent is to make it available in IDEs with Syntax highlighting, grammar linting etc


# This is a comment

# This is the most basic pattern, topic and that default to *
category: {
    pattern: {
        HELLO WORLD
    }
    template: {
        Hi there!
    }
}

# Specifically including topic and star
category: {
    topic: {*}
    that: {*}
    pattern: {
        HELLO WORLD
    }
    template: {
        Hi there!
    }
}

# Defining topic outside of category, will be topic scope for all categoies within {}
topic: TESTING {
    category: {
        that: {*}
        pattern: {
            HELLO WORLD
        }
        template: {
            Hi there!
        }
    }
}

# Matching a wild card directly to a variable
# !xxx -> Global Variable
# ?xxx -> Local Variable
category: { 
    pattern: {
        *!phrase
    }
    template: {
            You said !phrase
        }   
    }
}

category: { 
    pattern: {
        HELLO
    }
    template: {
        random:
            {Hello}
            {Hi}
            {Yo}
    }
}

category: { 
    pattern: {
        Who is *!name #?surname
    }
    template: {
        if:
            !name=='fred': {Hey Fred ?surname}
            !name=='mary': {Hey Mary ?surname}
        else: 
            {Don't know, run!!!}

    }
}
ohoachuck commented 4 years ago

Hello Keith, this is an excellent idea ! I love the idea of AIPL. How far are you in this ? Just while reading at your example, I had a first comment in my mind : how would you handle template content that will start by "if:" or "random:" (it can still happen right ?even if there are very little chances) ? An option might be to have an intermediary "code" like tag (something like "templatex" for instance): examples: category: { pattern: { Who is * !name# ? surname }

templatex: {
    if !name=='fred' OR 'mary': {
        template {
            Hey !name ? surname
        }
    }
    elif !name=='evil': {
        template {
            random: {
                { run ! ! ! }
                { call exrocist }
                { go toi church }
            }
        }
    else:
    template {
            Don 't know, run!!!
        }
    }
}

}

This is just "loud thinking". If I think twice, may be I'll find my comment stupid. So take it like this of course. Ok, I have started to think twice and I already find my "loud thinking" too complicated as the idea is to simplify ! So I came out with this thinking (python indentation style :-): category: pattern: Who is * !name# ? surname templatex: if !name=='fred' OR 'mary': template: Hey !name ? surname elif !name=='evil': template: random: run ! ! ! call exrocist '''go to church! And start praying ...''' else: template: Don 't know, run!!!

If I keep thinking I might delete my email thinking you'll get you mad at me flying away with no focus :). So l push send and not copying everyone :). O.

On 24 Sep 2019, at 09:58:18, Keith Sterling notifications@github.com wrote:

I've been playing round with defining a new language for AIML, during a recent project which required writing a lot of new and complex AIML the use of XML started to become the inhibitor of rapid development.

This is the bare bones of the language, it shows the basics of the grammar and how simple pattern matches are made up. Ive started work on a parser which converts to AIML, along with an AIML to the new langauge ( as yet unnamed, but possible AIPL - AI Programming Langauge )

The intent is to make it available in IDEs with Syntax highlighting, grammar linting etc

This is a comment

This is the most basic pattern, topic and that default to *

category: { pattern: { HELLO WORLD } template: { Hi there! } }

Specifically including topic and star

category: { topic: {} that: {} pattern: { HELLO WORLD } template: { Hi there! } }

Defining topic outside of category, will be topic scope for all categoies within {}

topic: TESTING { category: { that: {*} pattern: { HELLO WORLD } template: { Hi there! } } }

Matching a wild card directly to a variable

!xxx -> Global Variable

?xxx -> Local Variable

category: { pattern: { *!phrase } template: { You said !phrase }
} }

category: { pattern: { HELLO } template: { random: {Hello} {Hi} {Yo} } }

category: { pattern: { Who is *!name #?surname } template: { if: !name=='fred': {Hey Fred ?surname} !name=='mary': {Hey Mary ?surname} else: {Don't know, run!!!}

} }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/keiffster/program-y/issues/233?email_source=notifications&email_token=AAL454PP3G45ARPQZLFKQZLQLHCBVA5CNFSM4IZ4EJ52YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HNHSYRA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL454IKBV34COCTM7I7ZX3QLHCBVANCNFSM4IZ4EJ5Q.

keiffster commented 4 years ago

Hey, it’s still early days but I have the language basics in place and now adding all aiml tags. The first version will read aipl and convert internally to aiml before creating the parse tree. This way I can compare both parsing to and from aiml and ensure 100% compatible

All aiml tags will be supported so condition, random etc will be supported. Where it makes it easier then I am adding new aipl tags which translate to aiml. Eg if then else is just a much better condition and is condition under the hood.

However I may also add new tags to aipl which don’t map directly to aiml. This is in part frustration to how fast aiml spec is moving and also when you start developing aipl it creates lots of new ideas for variables and tags

Early days but having fun

ohoachuck commented 4 years ago

that's a really cool move.

O.

On 30 Sep 2019, at 12:27:16, Keith Sterling notifications@github.com wrote:

Hey, it’s still early days but I have the language basics in place and now adding all aiml tags. The first version will read aipl and convert internally to aiml before creating the parse tree. This way I can compare both parsing to and from aiml and ensure 100% compatible

All aiml tags will be supported so condition, random etc will be supported. Where it makes it easier then I am adding new aipl tags which translate to aiml. Eg if then else is just a much better condition and is condition under the hood.

However I may also add new tags to aipl which don’t map directly to aiml. This is in part frustration to how fast aiml spec is moving and also when you start developing aipl it creates lots of new ideas for variables and tags

Early days but having fun

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/keiffster/program-y/issues/233?email_source=notifications&email_token=AAL454K2DZLEDMLXBNTTCMTQMHIAJA5CNFSM4IZ4EJ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD75F33Y#issuecomment-536501743, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL454OBEUCWAUENCZYFQGDQMHIAJANCNFSM4IZ4EJ5Q.

ephraimd commented 4 years ago

Hey Keith! Awesome job you've been doing here, the world appreciates you sir. I've been watching the project from my inbox for a long time now and when I saw the AIPL Idea, It turned my attention a bit.

It's an awesome idea, I'll like to make an advise that the language contain as little noise as possible and focus more on the semantics just like python itself is.

I see a lot of symbols and braces already. I would like to point out that having the language start off not simple enough in the fundamentals might end up circling round to becoming a monster like AIML at the end.

I really wish you best of luck Keith, God Bless you! Thank you for program-y!

On Mon, 30 Sep 2019, 11:37 am ohoachuck, notifications@github.com wrote:

that's a really cool move.

O.

On 30 Sep 2019, at 12:27:16, Keith Sterling notifications@github.com wrote:

Hey, it’s still early days but I have the language basics in place and now adding all aiml tags. The first version will read aipl and convert internally to aiml before creating the parse tree. This way I can compare both parsing to and from aiml and ensure 100% compatible

All aiml tags will be supported so condition, random etc will be supported. Where it makes it easier then I am adding new aipl tags which translate to aiml. Eg if then else is just a much better condition and is condition under the hood.

However I may also add new tags to aipl which don’t map directly to aiml. This is in part frustration to how fast aiml spec is moving and also when you start developing aipl it creates lots of new ideas for variables and tags

Early days but having fun

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/keiffster/program-y/issues/233?email_source=notifications&email_token=AAL454K2DZLEDMLXBNTTCMTQMHIAJA5CNFSM4IZ4EJ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD75F33Y#issuecomment-536501743>, or mute the thread < https://github.com/notifications/unsubscribe-auth/AAL454OBEUCWAUENCZYFQGDQMHIAJANCNFSM4IZ4EJ5Q .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/keiffster/program-y/issues/233?email_source=notifications&email_token=AB7BYNQXHV2EV7E4JV3UAGTQMHJHHA5CNFSM4IZ4EJ52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD75GVWI#issuecomment-536505049, or mute the thread https://github.com/notifications/unsubscribe-auth/AB7BYNVAHCE5PGXKGYPK5SDQMHJHHANCNFSM4IZ4EJ5Q .

keiffster commented 4 years ago

Hi, thanks for the kind words, I've been working on the grammar and after some experiementation, I've moved to a more Lisp like version

( category (
    ( topic (*) )
    ( that (*) )
    ( pattern ( HELLO WORLD ) )
    ( template ( Hi there!))
  )
)

With topic and that optional, it becomes

( category (
    ( pattern ( HELLO WORLD ) )
    ( template ( Hi there!))
  )
)

I have also looked at make the core keywords optional, to the point where the grammar becomes

(  (
    ( ( HELLO WORLD ) )
    ( ( Hi there!))
  )
)

Thats a reduction on the xml variable of 50% characters

acriptis commented 4 years ago

I think there is no need for Another Dialog Markup Language. AIML is extensible (thanks to its XML nature). And any other language is just change of interface without addition of value.

From my point of view the main problem of AIML is lack of high level constructs which allow to construct more complex dialog behavior out of the box.

One of the greatest lack in AIML (and other dialog systems languages) is lack of Slots Filling behavior. So it would be great to specify some template that will be responsible for asking and handling the question such as "What is your name?" with proper extraction, normalization and validation of the slot value. Unfortunately it is very complex task for general solution (we need to decompose slots, because there are a plenty of ones: such as categorical, integer, string and other types of values) and requires dramatical extension of AIML standard.

keiffster commented 4 years ago

Thanks for the feedback, the primary reason for AIPL is exactly the problem you describe, its complex and messy to fill slots using AIML and XML, whereas with a new variant, simplfying tag structure and auto assignment of variables, it will make AIML development much quicker

I already have a prototype running and have coded 2 bots in it already and found it reduced development time by almost 50%, and found that code is approx 75% smaller. This is with a reduced set of features and an imcomplete grammar

So I'm going to stick with AIPL and continue to developer it, I may never release it and just keep it for my own work

ohoachuck commented 4 years ago

It’s true that it’s always risky to diverge from a standard. But innovation is different from creation. Innovation is improving what already exists based on lack of features and customer expectations/needs. That’s how languages and tools evolves. I think AIPL worth the try. Of course this is only my 2 cents from a little 🐸.

O.

Envoyé de mon iPhone

Le 12 nov. 2019 à 14:54, Keith Sterling notifications@github.com a écrit :

 Thanks for the feedback, the primary reason for AIPL is exactly the problem you describe, its complex and messy to fill slots using AIML and XML, whereas with a new variant, simplfying tag structure and auto assignment of variables, it will make AIML development much quicker

I already have a prototype running and have coded 2 bots in it already and found it reduced development time by almost 50%, and found that code is approx 75% smaller. This is with a reduced set of features and an imcomplete grammar

So I'm going to stick with AIPL and continue to developer it, I may never release it and just keep it for my own work

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

keiffster commented 4 years ago

To be clear AIPL is not a new language it transposes a simpler version of AIML into aiml. I already have a converter which can convert AIPL to AIML and AIML to AIPL. It’s a bit like Typescript which is really just JavaScript underneath.

AIPL is designed to speed up complex conversation development where you a complex arrangement of srai, topic, that and variables interacting through nested conditions

ohoachuck commented 4 years ago

👍 O.

Envoyé de mon iPhone

Le 12 nov. 2019 à 18:09, Keith Sterling notifications@github.com a écrit :

 To be clear AIPL is not a new language it transposes a simpler version of AIML into aiml. I already have a converter which can convert AIPL to AIML and AIML to AIPL. It’s a bit like Typescript which is really just JavaScript underneath.

AIPL is designed to speed up complex conversation development where you a complex arrangement of srai, topic, that and variables interacting through nested conditions

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.