RE: Evaluation flow, declaring new :response sentences and miscelany |
Great, this is working. I hate to reply to an excellent response with more questions, but that's excitement that it's getting closer.
// 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;
}
}
}
}
}
|
|
|
|
|