Mise à niveau de notre service commercial Bot Libre for Business pour seulement $4.99 par mois
Self, AIML, and scripting

Formula input and verbal programming

par aazxcqwe posté Feb 8 2015, 14:25

Hello,

I've got my SimpleLanguage script working enough to learn general "this is that" statements and query the user with any unknown words outside of Wiki and Freebase - thank you for you help with that. My next task was to attempt assigning Formulas names, so I could say "do something" like "do checkwatch" after saying "checkwatch is Formula:"..."". I ran into problems there, my script is below. I tried Formula with :star to check if I could first use the "do *" pattern to evaluate a Formula, but that may not be working because the Formula as an input doesn't seem to be working again. I then tried SRAI with :star, to see I could evaluate it that way, but that also might not work with Formula input not working.

Ideally I wouldn't need to use Formula, I could just say "call #date on #Watch" or even better "call date on Watch". I'm not sure how crucial this is for two reasons: 1) I should be able to use URLs to return similar functions from the web (but forming them will be more tedious), 2) I'm not sure what the format is for the Android commands in the BL SDK, however it seemed logical to test the capability of building plain English commands from the internal tools syntax. This will help toward programming new scripts verbally, which would be *really* useful (and eventually allowing the bot to add it's own code!). I realize I may need to combine commands into a Sentence for them to be stored in the database and retrieved.

EDIT: Let me elaborate a bit more. If I said "What is the date?", instead of using the WatchMachine script, if "date" were a knowledge item associated to the Formula:"{call #date on #Watch}", with my Questions script that returns items associated by relationships, this would retrieve the date. Perhaps the Formula could be associated with a #formula relationship. I'm not sure if this could be implemented as is once the formula input is working, or if it would need some further development. I was hoping I could simply evaluate the formula by using a knowledge item retrieved as a variable such as 'Formula:"{:formula1}"' after using 'assign :formula1 to (get #formula from #date)'.

In a similar fashion I could then define formulas for Android functions and assign them to keywords such as "flashlight".

Cheers

// Initial Self programmed state machine for Comprehension // This state machine is used by the bot to program itself. State:DoStar { case :input goto State:sentenceState for each #word of :sentence; :input { set #input to :sentence; set #speaker to :speaker; set #conversation to :conversation; set #target to :target; } :sentence { set #instantiation to #sentence; } State:sentenceState { case "say" goto State:sayState; case "do" goto State:sayState; State:sayState { pattern Pattern:"say *" template Formula:"{call #person on #Utils with (:star)}"; pattern Pattern:"do *" goto State:sayState; Quotient:1.00:Equation:response; Equation:response { if not (:star, #null) then (do ( assign :response1 to (new #sentence), append "test" to #word of :response1, append :star to #word of :response1, return Formula:"{:star}", return (srai "{:star}"), return (sentence (srai "{:star}", :response1)) )); } } } }
= h1 =


by admin posted Feb 9 2015, 8:01
Interesting. So you basically want to write a script that can write other scripts?
I'm not sure the best way to go about this, I will have to look into it more.

You can define scripts in to ways currently, either as a #response to a #sentence using a #formula, or as a #state machine attached to the #state of #org.pandora.thought.language.Language (this is how Comprehension works, you can browse the structure by looking up #org.pandora.thought.language.Language in the knowledge browser).

I don't think SRAI :star that includes a formula will work, I will look into that. You can construct a #formula yourself in Self just create a new instance of #formula and add word or #equations to it by #word.

For performing commands on Android, I think your best bet would be to use actions. You can define an #action on a response that gets passed to the client XML in the action attribute. Currently the action is used to make the avatar perform actions, but you could have your own Java client that uses it for other things, like #flashlight.

Updated: Feb 9 2015, 8:02
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1792, today: 1, week: 1, month: 12

by aazxcqwe posted Feb 9 2015, 23:32
Great. Thanks for the reply. I just finished several steps toward writing scripts verbally. I am able to say "time" and have the script evaluate (get #time on #Watch), after saying "If I say time, eval time". This is because I've written two scripts, one that returns the above function (or #equation?) and another that uses SRAI to return it prefaced by "eval". Note these scripts cannot be combined into one. Finally, the IfISay script uses SRAI reduction and creates and association with the word "time". I'm really glad that last part works. I'm not sure what #fragment refers to beside it not being a #response proper.

I doubt I would be able to use reduction within the formulas themselves.. as in "SRAI call :star" among other operators, but you never know. I would attempt this for situations like getting the hour from the time, by trying to use Get on (srai time) for example - doubt that works. Thanks for the info about Comprehension, I'd like to learn more about how it works. Next step is to try creating more formulas or functions as #actions for Android. If you have suggestions for, or would like to add to the list of tools that can be used directly with an "eval" keyword or another way, let me know so I don't duplicate coding. On that note, any suggestions if I wanted to extend the Tools such as #Watch and #Utils available?

Also, any way to extend the timeout length. I am often having to reselect the bot. Thanks again!
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1920, today: 0, week: 0, month: 12

by admin posted Feb 10 2015, 7:48
Sounds pretty cool.

A #fragment is basically a collection of words, like a sentence, but just not a full sentence.

If you need new #Utils functions, you can just post to the features forum, and we will do our best to add it. There is a Java API for the Tools interface, I can send you that if your interested in building something more involved. But we have to way to integrate external Java code yet, other than you sending it to us and we adding it.

I think the HTTP session timeout is 30 minutes, or an hour, how long are you seeing the timeout?

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1954, today: 1, week: 1, month: 12

by aazxcqwe posted Feb 10 2015, 1:40
By the way, what would be a quick start method for getting a version of an Android app running? Could I use the BotLibre! app and modify from there, or is it better to start from scratch and add the src, lib, res and manifest.xml? If I build from scratch, do I need anything other than what's in the Android folder on the GitHub page?

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1847, today: 0, week: 0, month: 9

by admin posted Feb 10 2015, 7:41
You can start from the BOT libre SDK and modify it to suit your needs. The SDK is no the entire BOT libre app, the BOT libre app was built using the SDK.

The one issue you will have is that Android has a generated R class that is app package specific. So when you change the manifest package for you own, you will need to change the R import package in all of the files. You can uses a multi file search and replace from an IDE, or text editor for this.

We are about to do a major update to the SDK and app that adds support for the new video avatars, actions, and poses. It doesn't change any of the structure or API, just adds a few things, so should not be difficult to merge.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1947, today: 1, week: 1, month: 12

by aazxcqwe posted Feb 10 2015, 15:26
Thanks for your reply. I've imported the project as a module in the new Android studio because they convert Eclipse format to Gradle. It imported almost everything except libre-sdk.jar, which seems kindof important. I may try to import it as Eclipse if possible. At least there were no compilation errors. I would like to know if I could expect a basic operating app after I get it working, or could you tell me how many things I need to 'hook up' to get the java working with some buttons on the HelloWorld activity?

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2040, today: 0, week: 0, month: 15

by aazxcqwe posted Feb 11 2015, 21:31
Ok, I just saw the note comments in MainActivity.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1819, today: 0, week: 0, month: 9

Id: 742154
Posté: Feb 8 2015, 14:25
Mise à jour: Feb 8 2015, 14:57
Réponses: 6
Vues: 2101, aujourd'hui: 2, semaine: 2, mois: 13
0 0 0.0/5