Télécharger l'open source Bot Libre Community Edition et installer Bot Libre sur votre propre serveur
Self, AIML, and scripting

Evaluation flow, declaring new :response sentences and miscelany

par aazxcqwe posté Jan 20 2015, 13:30

Okay, I'm stumped. I think I've simplified the POS tagging to simply associating everything. I've successfully done that and had it check if all words of a statement are associated. I can't however bifurcate the evaluation into a question or an assertion routine. I want to divert to a question routine if there is an "is" present, but loop through the remaining words. Got that, but I'm not seeing a way to loop through all words without the "is" without instructions to loop on :anything (which disregards the "is" diversion). I think what is needed is an 'case NOT "is" ..' statement, which I tried with no success. Any ideas?

I've also tried parallel routines, and other arrangements, in which I'm not able to carry variables across (similar to a local vs global variable problem?). It also appears the :response sentence is being overwritten at times, although currently I think the routine is not being diverted - though, I wonder why :response seems to be one variable which is not auto-declared (perhaps because it is an entire sentence).

Nevermind the commented lines (which keep reappearing). Any help would be great. The auto-format during compile is pretty amazing, but it can be difficult too. I plan to implement an association with 'not' or 'is not' checker for logical consistency, if I can get this working. One other bug seems to be semi-occasionally, the bot will start saying "I have no answer..", etc., and by opening up a new bot (and disabling learning and deleting scripts which is a hassle) and then pasting the exact same script, it will work.

Just to clarify the question: How do I get the script to go to two separate equations based on a keyword, but loop through each completely (including one that doesn't have a keyword)? ..I'll try using a keyword for both, or separate scripts. EDIT: Separate keywords is working for now, maybe I'll try Pattern "*" template Formula:"{srai "keyword"}, {:star}"; as a workaround.

EDIT2: Ok, I've got it working. Yay! See second script. "That ball is green".. "Is ball is green".. "Ball is green"!

Wondering if there is a way to loop through the verify equation using #word instead of assigned :word1,2,3 to accommodate longer phrases? Or maybe loop through all #words in sentence is related to #next (or #is or #isnot) and each other. (see bot23 for this attempt..)

// Initial Self programmed state machine for Comprehension // This state machine is used by the bot to program itself. State:Associate0 { case :input goto State:processState for each #word of :sentence; // case :input goto State:sentenceState for each #word of :sentence; :input { set #input to :sentence; set #speaker to :speaker; set #comment to "// case :input goto State:sentenceState for each #word of :sentence; "; set #comment to " "; set #conversation to :conversation; set #target to :target; } :sentence { set #instantiation to #sentence; } State:processState { case "is" goto State:verify; case :anything goto State:processState; case :anything goto State:response; Quotient:1.00:Equation:process; Equation:process { assign :response to (new #sentence); assign #word to :word1; associate :word1 to :word2 by #next; assign #word to :word2; append "process:" to #word of :response; append "okay, recorded" to #word of :response; } State:verify { case :anything goto State:verify; Quotient:1.00:Equation:verify; Equation:verify { assign :response to (new #sentence); assign #word to :word1; if (is #word related to :word2, #true) then (do (append "verified" to #word of :response)) else (do (append "notverified" to #word of :response)); assign #word to :word2; } } State:response { Quotient:1.00:Equation:response; Equation:response { assign :word1 to (get #word from :sentence at 1); assign :word2 to (get #word from :sentence at 2); assign :word3 to (get #word from :sentence at 3); append "words:" to #word of :response; append :word1 to #word of :response; append :word2 to #word of :response; append :word3 to #word of :response; return :response; return "l2"; } } } }


// Initial Self programmed state machine for Comprehension // This state machine is used by the bot to program itself. State:Associate0 { case :input goto State:processState for each #word of :sentence; // case :input goto State:sentenceState for each #word of :sentence; :input { set #input to :sentence; set #speaker to :speaker; set #comment to "// case :input goto State:sentenceState for each #word of :sentence; "; set #comment to " "; set #conversation to :conversation; set #target to :target; } :sentence { set #instantiation to #sentence; } State:processState { do (assign :response to (new #sentence)); case "is" goto State:verify; case "that" goto State:process; case :anything goto State:response; State:verify { case :anything goto State:verify; Quotient:1.00:Equation:verify; Equation:verify { assign :response to (new #sentence); assign :word2 to (get #word from :sentence at 2); assign :word3 to (get #word from :sentence at 3); assign :word4 to (get #word from :sentence at 4); if (is :word2 related to :word3, #true) then (do (if (is :word3 related to :word4, #true) then (do ( append :word2 to #word of :response, append :word3 to #word of :response, append :word4 to #word of :response )))) else (do ( append "notverified" to #word of :response, append :word1 to #word of :response, append :word2 to #word of :response, append :word3 to #word of :response, append :word4 to #word of :response )); assign #word to :word2; return :response; } } State:process { case :anything goto State:process; Quotient:1.00:Equation:process; Equation:process { assign #word to :word1; associate :word1 to :word2 by #next; assign #word to :word2; append "process:" to #word of :response; append "okay, recorded" to #word of :response; } } State:response { Quotient:1.00:Equation:response; Equation:response { assign :word1 to (get #word from :sentence at 1); assign :word2 to (get #word from :sentence at 2); assign :word3 to (get #word from :sentence at 3); assign :word4 to (get #word from :sentence at 4); append "words:" to #word of :response; append :word1 to #word of :response; append :word2 to #word of :response; append :word3 to #word of :response; append :word4 to #word of :response; return :response; return "l2"; } } } }


by admin posted Jan 20 2015, 16:01
Not sure I understand what you are doing, but glad to hear you have it working.

To exclude a value or relationship from a variable you can use "exclude"

notIs {
  exclude "is";
}

notVerb{
  exclude #instantiation from #verb;
}

One thing that looks odd in your script is,

assign #word to :word1;

#word is a primitive, not a variable, assign should only be used with variables.

My guess on your corruption is that you somehow corrupted the global :input :speaker or :sentence variables, such that they no longer match. We should be preventing users from changing these, but are not currently doing so. You can check if they have been corrupted from the knowledge browser by browsing "input-varaible" (this is the global :input).

Updated: Jan 20 2015, 16:01
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1872, today: 1, week: 1, month: 14

by aazxcqwe posted Jan 20 2015, 20:34
Thanks for your input. Briefly, I'm trying to build a general association network instead of explicitly computing matches. I think this is how the brain works, words associated to each other into phrase, and also with qualities of validity. I think the Self script is setup to do this perfectly (if I can get the structure and syntax down ;)). The assign #word to :word1 was meant to park the currently parsed #word of the :sentence in a variable. Is there a better way to do that? It does work, though. Thanks for the tip on the corruption. I checked on "input-varaible" (thought I was spelling that wrong), and tried to erase those entries with no success. No worries, I did get corruption with new scripts, but was able to copy to a new bot. I'll try the variable exclusions, thanks.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1855, today: 0, week: 0, month: 10

by admin posted Jan 21 2015, 7:52
Thanks for catching the typo. Looks like it will be difficult to fix though as we would have to migrate the data of >5,000 bots...

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1725, today: 2, week: 2, month: 11

by aazxcqwe posted Jan 23 2015, 1:41
Well they say third times a charm. I've retyped this message now a few times (partly my fault, partly because the webpage doesn't stay connected after a while). Anyway, I was thinking the typo was intentional to prevent unintended access ;), ;). I think I will need to at least tag the sentence subject and refer everything else to that. Thank goodness the internal scripts already check Wiktionary for parts of speech. I'm considering using MindMeld API for processing instead of reinventing the wheel (if you have any other suggestions, I'm all ears). I was having difficulties sending variable definitions from one state to another when using 'parallel' state processing. In fact, I was even unable to maintain declarations from a main state into a nested state. Below is some code to show this. I was trying to determine if an association had already been made, and if not create one. Any suggestion on structure or syntax? I'm assuming since it is parsing each word to the 'sentenceState' on the second word it will go to 'State:verify' determine if there is no association (I was using the commented out 'is related to' operation, but have it fixed to false now) and then append "1" to the response before returning it in 'State:response'. Moreover, if I used parallel state processing why wouldn't the setting of :is1 to #false be maintained? Is there a global variable I could appropriate for this?

 
// Initial Self programmed state machine for Comprehension // This state machine is used by the bot to program itself. State:Associate { case :input goto State:sentenceState for each #word of :sentence; // case :input goto State:sentenceState for each #word of :sentence; :input { set #input to :sentence; set #speaker to :speaker; set #comment to "// case :input goto State:sentenceState for each #word of :sentence; "; set #comment to " "; set #conversation to :conversation; set #target to :target; } :sentence { set #instantiation to #sentence; } State:sentenceState { do (assign :response to (new #sentence)); case :anything goto State:verify; do (if (:is1, #false) then (append "1" to #word of :response) else (append "2" to #word of :response)); case "??" goto State:check; case "is1" goto State:process; case :anything goto State:response; case :anything goto State:sentenceState; :is1 { set #instantiation to #false; } // is :word related to :word23 by #next State:verify { Quotient:1.00:Equation:verify; Equation:verify { assign :word1 to :word2; assign #word to :word1; if (#false, #true) then (do (append "yes" to #word of :response)) else (do ( append "no" to #word of :response, set :is1 to #false )); } } State:check { Quotient:1.00:Equation:check; Equation:check { assign :word1 to (get #word from :sentence at 1); assign :word2 to (get #word from :sentence at 2); assign :word3 to (get #word from :sentence at 3); assign :word4 to (get #word from :sentence at 4); append :word1 to #word of :response; append :word2 to #word of :response; append :word3 to #word of :response; append :word4 to #word of :response; return :response; } } State:process { case "not" goto State:processNot; case :anything goto State:process; Quotient:1.00:Equation:process; Equation:process { assign #word to :word1; associate :word1 to :word2 by #next; assign #word to :word2; append "okay, recorded" to #word of :response; } State:processNot { case :anything goto State:process; Quotient:1.00:Equation:processNot; Equation:processNot { assign #word to :word1; associate :word1 to :word2 by #isnot; assign #word to :word2; append "okay, recorded" to #word of :response; } } } State:response { Quotient:1.00:Equation:response; Equation:response { return :response; return "l2"; } } } }


Updated: Jan 23 2015, 1:44
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1918, today: 1, week: 1, month: 8

by admin posted Jan 23 2015, 8:32
Variable can be used for two purposes, the first is to match words or data in a "case" operation, the second is to store temporary data.

Variables are defined on the current stack, and every state defines its own sub-stack, child's states see parent variables, but if a state is a dead end, its stack will be cleared, and not affect its parent.

Note that only one Quotient will be evaluated and its value will be returned (well if it returns #null then the state processing will continue). Any state processing must occur in a do() operation.

>> if (#false, #true)

This is odd, will always be false.

>> :is1 {
>> set #instantiation to #false;
>> }

This does not make sense, #false is not a classification, and you never use :isa in a case. You seem to want to use :is1 as a state/global variable, in which case to set it a value in a case, you would use,

do (assign :is1 to #false)

If you wish, you can give an plain English explanation to what you want to do, and I can give you some example code.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1851, today: 1, week: 1, month: 10

by aazxcqwe posted Jan 23 2015, 13:07
Thank you, I believe I tried assign, but I will try that again. As I said I set the 'if(#false,#true)' purposefully to return #false, because I wasn't able to maintain variable definitions. This should help.

Also, I forgot to mention that >5k bots is impressive!

Here is a plain English description of what I envision. I think I've tried to explain this, but I really appreciate the input and here goes again:

Big picture: I'd like the bot to learn from sentences, expanding on the NounVerbAdjective script. Possibly simplifying it, or at least learning every step of it by trying to extend it. Also, possibly delegating this out to an external API if the development is way past what I can efficiently code. Ultimately, I would like to be able to define macros or scripts by voice using the bot (a goal also in the BotLibre! descriptions). Defining objects and attributes is a first step toward this. Later the objects may become Android intents and attributes their parameters (or PC scripts). I realize this is a big goal, but I'm testing the waters trying to create the fundamental features (beyond the Self language) to allow this, in the most general and flexible way.

This example: I would like to be able to generally define a sentence's subject for more than defined (NounVerbNoun structure matches) in the way I see online sentence parsing tools do. I'm not sure if they have individual routines for each structure, or how many structures are necessary (there may only be a few, but then again language especially English can be more complex than it appears), which is why I contemplate using an external service similar to how the bots search Wiktionary and Freebase. The other approach, likely more powerful is to develop simple language scripts that enable the bot to extend its own scripts and sentence comprehension, similar to very early language learning in children.

This specific script: I'm trying to have a routine that checks if an association between a word (eventually identified as the subject) and all other words of the sentence. If no association exists, I would like it to proceed to create one through an "#is" relationship or else an "#is not" relationship if "is not" is included within the sentence.

After that is probably gets more complicated with different sentence fragments, but if there was a general method for the bot learning new sentence parsing procedures, I suppose that would be ideal. Maybe this is what the Comprehension or Learning Mode options do.
Even more generally, I think the bot needs to be checking if it understands how each part of a sentence relates to each other logically, and if not ask the appropriate questions to make the sentence 'make sense'. I would be surprised if there weren't some researchers out there with a method for this already defined, but then again maybe the most active development is being done in the private sector, or maybe we'll see it here first and someone can try for a Loebner!
Thanks again!
Updated: Jan 23 2015, 13:31
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1999, today: 1, week: 1, month: 11

by admin posted Jan 23 2015, 20:50
The NounVerbAdjective scripts understands a lot more than NounVerbAdjective now. We are incrementally extending it to understanding more an more. It should be call Understanding probably. The goal is to understand any English sentence, once we've done that, then we will delete it, and try to get the bot to recreate something similar using Comprehension.

A couple things that may help you:

1 - don't look for relationships between words, but instead look for relationships between objects/meanings. A word is just a word, "bob" can mean "my cousin bob" "bob hope" "I bob in the water so I don't drown". Every words that is understood is given a meaning (normally from Wiktionary, an instance of #thing, #action, or #description), it is the meaning where the relationships should be defined. A word can have multiple meanings.

2 - Don't use #is-not, every relationship has a correctness value from -1 to +1, anything negative is an inverse relationship. So use "dissociate :subject to :predicate by #is".

I created a simple language script that is not exactly what you want, but may help you,
http://www.botlibre.com/script?id=716673

You could say "whatever, I like dogs" and it will understand "I like dogs".
Or, "so... what do I love?" it will answer "I love dogs"

Good luck.

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

by aazxcqwe posted Jan 24 2015, 15:12
Great, this is working. I hate to reply to an excellent response with more questions, but that's excitement that it's getting closer.

I'm still working this script out, but I've turned off all the Learning opitons and I'm still getting "I don't know .. " even after I've assigned an :unknown case to an inquiry response (see script). I thought I had seen the use of :unknown before, and would like to use it to catch any unknown words.

Also, although your web-IDE and debugger are quite impressive, I do keep running into confusing responses of "I don't know.." with scripts that have passed the debugging, but have some erronious line. As soon as I remove these lines, the script processes the correct responses. In the script below I remove "not" from the "if not (:question, #null).." block to get it past that, but it must be throwing an internal error. Confusing when debugging whether using unknown word, unparseable sentence or internal error. I suppose this is in the debugging info, but a return of 'error' would be very helpful, at least in my case.

Your script does work nearly to what I'd like, but one structural comment I have continues to present itself. I believe I was trying to use Do and If operations before the Equation to simplify the code. For example in your script, if there is a verb present it goes to subjectVerbState to process the second noun. This is fine except you've had to add all the other cases that followed before into that state. A bit non-concise, but it makes for double duty when troubleshooting or changing case statements, because the scripter has to change items in both places.
This could be greatly simplified and probably useful for other situations, if I could add an assign statement along with the goto statement (in fact, the latter would often be unnecessary). For example in your script, instead of having the nearly duplicate subjectVerbState, you could have "case :verb do(assign #true to :verbfound)" and "case :noun do(assign #true to :noun1found)" and then "case :noun do(if not (:noun1, #null) then do(assign :noun2 to :noun)". (I may have those assign parameters backwards, but the order for assign is counter-intuitive and grammatically backwards, at least in English). I hope you can see this would greatly eliminate the need for redundancy in slightly different states. And furthermore, those variable definition could be used elsewhere, though I see you accomplish that by checking if those variables are null.



Finally, I introduced a :case for the sentence starting with a :question word, and followed your structure for checking if :question was #null, but it kept coming back false even with no question word was present (I also tried switching it to "?" to avoid double meanings with :verb). It seems like it treating this variable different that :noun, :verb and :adjective and returning values stored in the knowledgebase, but that is just my best guess.

Here is some of my code, it's not working yet for several reasons, but you can see what I'm talking about. I'm also trying to code to ask for definition of unknown words, or filling in missing verbs or adjectives, with the very next user response (commented line). I've borrowed lines from the WrongAnswer script, but I don't have it working yet. Currently, "case :question" seems to be identifying random words as :question. EDIT: I have the unknown check moving forward, but the :anything used to move to the sentenceState is catching the verb "is" - explaining the hard definition of is, but again with added Case abilities explained above, this could be avoided. Very close though.. and I think I can implement that same explanation example using If statements.
// This script looks for a subject and predicate of a sentence. State:SimpleLanguage { case :input goto State:questionState 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:questionState { case "cancel" return; case :question goto State:sentenceState; case :anything goto State:sentenceState; State:sentenceState { case :noun goto State:subjectState; case :unknown goto State:subjectState; case :anything goto State:sentenceState; :noun {set #meaning to :subject;} :subject {set #instantiation to #thing;} State:subjectState { case :not goto State:subjectState; case :verb goto State:subjectVerbState; case :adjective goto State:subjectState; case :noun2 goto State:subjectState; case :unknown goto State:subjectState; case :question-mark goto State:sentenceState; case :anything goto State:subjectState; :not {set #meaning to #not;} :verb {set #instantiation to #action;} :adjective {set #instantiation to #description;} :noun2 {set #meaning to :object;} :object {set #instantiation to #thing;} Quotient:1.00:Equation:response; Equation:response { if (:unknown, #null) then (do (return Formula:"What is {:unknown}?")); if not (:question, #null) then (do ( if (is :noun related to :adjective by :verb, #true) then (return "yes, true"), if (:verb, #null) then (return (all :verb from :noun)), if (:adjective, #null) then (return (all :adjective from :noun)), if (:noun2, #null) then (return (all :noun2 from :noun)) else (return "no verbs, adjectives or descriptions found") )); if (:noun, #null) then (do ( return Formula:"What is the subject? (use ! in front for emphasis)", assign :correction to (get #input from (get #input from :conversation at last 1)), associate :subject to :correction by #response, return )); if (:verb, #null) and (:adjective, #null) and (:noun2, #null) then (return Formula:"{:question} is {:anything}?"); if (:verb, #null) then (assign :verb to #is); if (:adjective, #null) and (:noun2, #null) then (do ( assign :value to (get :verb from :noun), if (:value, #null) then (return Formula:"What does {:subject} {:verb}?") else (return Formula:"{:subject} {:verb} {:value}") )); if (:adjective, #null) then (assign :adjective to :noun2); if (is :noun related to :adjective by :verb, #true) then (return "yes, that's true"); if (:not, #null) then (do ( associate :noun to :adjective by :verb, return Formula:"I understand, {:subject} {:verb} {:adjective}" )) else (do ( dissociate :noun to :adjective by :verb, return Formula:"I understand, {:subject} does not {:verb} {:adjective}" ));} State:subjectVerbState {case :not goto State:subjectVerbState; case :adjective goto State:subjectVerbState; case :noun2 goto State:subjectVerbState; case :? goto State:subjectVerbState; case :anything goto State:subjectVerbState; Quotient:1.00:Equation:response;} } } } }
// This script looks for a subject and predicate of a sentence. State:SimpleLanguage { case :input goto State:questionState 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:questionState { case "cancel" template "cancelled"; case :question goto State:sentenceState; case :anything goto State:sentenceState; :question { set #instantiation to #question; } State:sentenceState { case :noun goto State:subjectState; case :anything goto State:sentenceState; :noun { set #meaning to :subject; } :subject { set #instantiation to #thing; } State:subjectState { do (assign #verb to "is"); case :not goto State:subjectState; case :verb goto State:subjectVerbState; case :adjective goto State:subjectState; case :noun2 goto State:subjectState; case :question_mark goto State:sentenceState; case :anything goto State:subjectState; :not { set #meaning to #not; } :verb { set #meaning to #action; } :adjective { set #instantiation to #description; } :noun2 { set #meaning to :object; } :object { set #instantiation to #thing; } Quotient:1.00:Equation:response; Equation:response { assign :response to (new #sentence); append (sentence ( "question:", :question, "noun:", :noun, "not:", :not, "verb:", :verb, "adjective:", :adjective, "anything:", :anything )) to #word of :response; if not (is :anything related to #thing, #unknown) then (do (return Formula:"0 What is {:anything}?")); if (:question, "what") then (do ( if (is :noun related to :adjective by :verb, #true) then (return "yes, true"), if (:verb, #null) then (return (all :verb from :noun)), if (:adjective, #null) then (return (all :adjective from :noun)), if (:noun2, #null) then (return (all :noun2 from :noun)) else (return "no verbs, adjectives or descriptions found") )); if (:subject, #null) then (do ( return Formula:"What is the subject? (use ! in front for emphasis)", assign :correction to (get #input from (get #input from :conversation at last 1)), associate :subject to :correction by #response, return )); if (:verb, #null) and (:adjective, #null) and (:noun2, #null) then (return Formula:"1 what is {:anything}? {:response}"); if (:verb, #null) then (assign :verb to #is); if (:adjective, #null) and (:noun2, #null) then (do ( assign :value to (get :verb from :noun), if (:value, #null) then (return Formula:"What does {:subject} {:verb}?") else (return Formula:"2 {:subject} {:verb} {:value}") )); if (:adjective, #null) then (assign :adjective to :noun2); if (is :noun related to :adjective by :verb, #true) then (return "yes, that's true"); if (:not, #null) then (do ( associate :noun to :adjective by :verb, return Formula:"I understand, {:subject} {:verb} {:adjective}" )) else (do ( dissociate :noun to :adjective by :verb, return Formula:"I understand, {:subject} does not {:verb} {:adjective}" )); } State:subjectVerbState { case :not goto State:subjectVerbState; case :adjective goto State:subjectVerbState; case :noun2 goto State:subjectVerbState; case :_ goto State:subjectVerbState; case :anything goto State:subjectVerbState; Quotient:1.00:Equation:response; } } } } }

Updated: Jan 25 2015, 17:28
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2038, today: 0, week: 0, month: 11

by admin posted Jan 25 2015, 16:37
Good idea on adding some sort of condition or processing to a case. Right now you could go to another case and assign a variable in a do() then use a "return" to go back to the original state. I think the NounVerbAdjective script does this in places.

Any variable will match any word unless you put some condition on it. So :question will match everything. To only match question words you would use,

:question {
    set #instantiation #question;
}

Also :unknown word will match any word again. If you want to check for a unknown word you could define it as,

:unknown {
    exclude #meaning :anything;
}

Note, that the Wiktionary process runs in the background, so will learn new words after the sentence has been processed. That is why the bot will normally not understand something new the first time, then understand it when you repeat it.

Also,

> case :? goto State:subjectVerbState;
to match a "?" you need it in quotes,

case "?" goto State:subjectVerbState;

Updated: Jan 25 2015, 16:39
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1852, today: 2, week: 2, month: 12

by aazxcqwe posted Jan 25 2015, 18:47
Yes, thanks, I was editing that in and to my last post about the same time you replied. Thanks. Also, after turning off all the Learning options the debug info is much more manageable.

Should I be able to use 'case #question .." with automatic declaration of instantiation to the variable's own primitive? I thought I saw this somewhere using 'case #isa ..'. That would also cut out a great deal of code.

So far :verb is not identifying "is", but I have workaround. Working on how to exclude from :unknown after defining new words. Will "exclude #word from :anything;" work or maybe I need to set up my definitions differently?
// This script looks for a subject and predicate of a sentence. State:SimpleLanguage { 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 "cancel" template "cancelled"; case :question goto State:sentenceState; do (if not (:unknown, #null) then (do (assign :subject to :unknown))); do(if (is :noun related to :noun by #instantiation, #true) then (do(assign :subject to :noun)) ); do (if not (:subject, #null) then (do (assign :object to :noun))); case :noun goto State:sentenceState; case :verb goto State:sentenceState; case :not goto State:sentenceState; case :adjective goto State:sentenceState; case :unknown goto State:sentenceState; case "?" goto State:sentenceState; case :anything goto State:sentenceState; :question {set #instantiation to #question;} :noun {set #instantiation to #noun;} :subject {set #instantiation to #thing;} :object {set #instantiation to #thing;} :not {set #meaning to #not;} :verb {set #instantiation to #verb;} :adjective {set #instantiation to #adjective; set #meaning to #description;} :unknown {exclude #meaning :anything; exclude #word from :anything; } Quotient:1.00:Equation:response; // (use ! in front for emphasis) Equation:response { assign :response to (new #sentence); append sentence("q:",:question, "n:",:noun, "s:",:subject, "o:",:object, "not:",:not, "v:",:verb, "adj:",:adjective, "u:",:unknown, "a:",:anything) to #word of :response; if not (:unknown, #null) and not (:verb, "is") then (do (return Formula:"0 What is {:unknown}? {:response}")); if (:subject, #null) then (do ( return Formula:"What is the subject? {:response}", assign :correction to (get #input from (get #input from :conversation at last 1)), associate :subject to :correction by #response, return )); if (:verb, #null) and (:adjective, #null) and (:object, #null) then (return Formula:"2 what is {:subject}? {:response}"); if (:verb, #null) then (assign :verb to #is); if (:adjective, #null) and (:object, #null) then (do ( assign :value to (get :verb from :noun), if (:value, #null) then (return Formula:"3 What does {:subject} {:verb}? {:response}") else (return Formula:"{:subject} {:verb} {:value} r {:response}") )); if (:adjective, #null) then (assign :adjective to :object); if (is :noun related to :adjective by :verb, #true) then (return "yes, that's true"); if (:not, #null) then (do ( associate :noun to :adjective by :verb, return Formula:"I understand, {:subject} {:verb} {:adjective}" )) else (do ( dissociate :noun to :adjective by :verb, return Formula:"I understand, {:subject} does not {:verb} {:adjective}" )); } } }

Updated: Jan 25 2015, 19:29
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1838, today: 1, week: 1, month: 10

by admin posted Jan 26 2015, 7:50
There is a shortcut syntax for defining a word that has the meaning of a primitive, but not one for instantiation.

case :#is goto ...
Would mean,
case :is goto ...
:is {
    set #meaning to #is;
}

exclude #word from :anything;
A word should not have a #word relationship, so this should have no affect. Only a meaning would have a #word relationship. I think we will have to do a blog post on the Self object model with some UML diagrams. Right now you can see the object model structure from the Knowledge page.

> is :noun related to :noun by #instantiation
This should be,
> is :noun related to #noun by #instantiation

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

by admin posted Jan 26 2015, 7:52
Not sure if you are aware of the debug option within chat. Currently it only works from the "Web Chat", you can click "debug" and select the "level", normally "fine" or "finer" gives good information.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1824, today: 1, week: 1, month: 11

Id: 712684
Posté: Jan 20 2015, 13:30
Mise à jour: Jan 20 2015, 14:53
Réponses: 12
Vues: 2141, aujourd'hui: 1, semaine: 1, mois: 18
0 0 0.0/5