We test whether a human has understood a story by asking questions, first to check on retention of explicitly stated facts, then for the ability to draw reasonable conclusions.
(tell '((:clear-slot *context* current)
(current *context* ja-story))
:comment "In the John Alden story ...")
(ask '((:the ?me (speaker (current *context*) ?me))
(:the ?w (wife ?me ?w))
(age ?w ?a ?units)
(name ?w ?n))
:collect '(?n is ?a ?units old)
:comment "How old is my wife?")
The :collect keyword provides restructured output.
QUERYING: How old is my wife?
Input preds: (:the ?me (speaker (current *context*) ?me))
(:the ?w (wife ?me ?w)) (age ?w ?a ?units) (name ?w ?n)
Result:
Bindings: ?n --- "priscilla"
?units --- years
?a --- 23
?w --- frame1-wife "priscilla"
?me --- frame1 "john alden"
?$x20 --- ja-story
=> (("Priscilla" IS 23 YEARS OLD))
(ask '((husband Priscilla ?h)
(:eval (pp-frame '?h))
(name ?h ?n))
:comment "Who is Priscilla's husband?"
:collect '?n)
The special :eval form applies the lisp function pp-frame to the frame bound to the variable ?h, to display it on the terminal. Then the name is returned.
QUERYING: Who is Priscilla's husband?
Input preds: (husband priscilla ?h) (:eval (pp-frame (quote ?h)))
(name ?h ?n)
Frame1:
Isa: things objects physical-objects people
Name: "john alden"
Age: (25 years)
Wife: frame1-wife
Gender: male
Spouse: frame1-wife
Result:
Bindings: ?n --- "john alden"
?h --- frame1 "john alden"
=> ("John Alden")
(ask '((name (friend Priscilla) ?name))
:comment "What is Priscilla's friend's name ?"
:collect '?name)
Here we collect two names into a list.
QUERYING: What is Priscilla's friend's name ?
Input pred: (name (friend priscilla) ?name)
Result (1 of 2):
Bindings: ?name --- "cotton mather"
?$x21 --- |cotton mather|
Result (2 of 2):
Bindings: ?name --- "miles standish"
?$x21 --- |miles standish|
=> ("Miles Standish" "Cotton Mather")