Exemplo n.º 1
0
def add_line(asker, view, new_line):
    return asker.reply(answer=updates.update(
        updates.apply_to_field(
            lines_field(),
            lists.append(new_line)
        ),
        view
    ))
Exemplo n.º 2
0
 def easy_set(asker, object, new_value):
     #FIXME the cyclic import again, would be nice to do better
     import updates
     return asker.reply(answer=updates.update(
         updates.apply_to_field(
             modifier(), 
             updates.set_field(implication_about(field), new_value)
         ),
         object
     ))
Exemplo n.º 3
0
def bind_variable(asker, view, name, value):
    return asker.reply(answer=updates.update(
        updates.apply_to_field(
            bindings_field(),
            updates.set_field(
                dictionaries.image(name),
                value
            )
        ),
        view
    ))
Exemplo n.º 4
0
 def propagate_back(s):
     if s.head == term.because.head:
         return propagate_back(s['operation'])
     elif s.head == term.explain.head:
         return propagate_back(s['operation']) or propagate_back(s['prior'])
     elif s.head == term.accessing.head:
         if change.head == updates.trivial.head:
             parent = s['term']
             binding = s['binding']
             return self.update(
                 updates.trivial(),
                 parent,
                 repr_change=updates.apply_to_field(
                     representations.referent_of(T.from_str(binding)),
                     repr_change
                 ).explain("tracing backwards from [v]", v=v)
             )
         else:
             return False
     elif s.head == askers.answering.head:
         Q = s['Q']
         if Q.head == fields.get_field.head:
             parent = Q['object']
             field = Q['field']
             return self.update(
                 updates.apply_to_field(field, change), 
                 parent, 
                 repr_change=updates.apply_to_field(updates.lift_field(field), repr_change)
             )
         elif Q.head == convert.convert.head:
             previous = Q['value']
             return self.update(
                 change,
                 previous,
                 repr_change=None
             )
     return False
Exemplo n.º 5
0
def predict_input(asker, view):
    lines = fields.get(asker, lines_field(), view)
    h = asker.ask(state.get_history()).firm_answer
    response = asker.ask(fields.get_field(dictionaries.image(lines), h))
    if response.has_answer():
        return asker.reply(answer=response.answer)
    else:
        input = asker.ask_firmly(elicit(view))
        asker.ask(state.update_state(updates.apply_to_field(
            state.history(),
            updates.set_field(
                dictionaries.image(lines),
                input
            )
        )))
        return asker.reply(answer=input)
Exemplo n.º 6
0
def update_history(asker, update):
    asker.ask(update_state(updates.apply_to_field(history(), update)))
    asker.reply()