Esempio n. 1
0
def objectPropertySolutions(agent, bindings, zexpr, propname_given):
    "Generator that returns a tuple (obj, propname, val) for each solution"
    d1 = agent.getInfo(P_ObjectProperty)
    obj_iter = makeSequence(termEvalOpt(agent, bindings, zexpr[0]))
    propname_iter = makeSequence(propname_given)
    for obj in obj_iter or d1:
        d2 = d1.get(obj, NULLDICT)
        if d2 and (obj_iter or termMatch(agent, bindings, zexpr[0], obj)):
            for propname in propname_iter or d2:
                val = d2.get(propname)
                if val is not None \
                       and termMatch(agent, bindings, zexpr[2], val) \
                       and (propname_iter or termMatch(agent, bindings, zexpr[1], propname)):
                    yield (obj, propname, val)
Esempio n. 2
0
 def tchild_complete(self, agent, tframe, zexpr, index, result):
     if index == 0:
         if result is SUCCESS:
             return tframe.tfpost_child(agent, 1)
         elif termMatch(agent, tframe.getBaseBindings(), zexpr[2], result):
             return tframe.tfpost_child(agent, 3)
         else:
             raise zexpr.error("Pattern does not match value %s", result)
     else:
         return tframe.tfcompleted(agent, result)
Esempio n. 3
0
 def tchild_complete(self, agent, tframe, zexpr, index, result):
     if index == 0:
         if result is SUCCESS:
             return tframe.tfpost_child(agent, 1)
         elif termMatch(agent, tframe.getBaseBindings(), zexpr[2], result):
             return tframe.tfpost_child(agent, 3)
         else:
             raise zexpr.error("Pattern does not match value %s", result)
     else:
         return tframe.tfcompleted(agent, result)