eg:
list-kets |movie: *> returns the list of all movies (in the current context)
list-kets |person: *> returns the list of all people
list-kets |animal: *> returns the list of all animals
list-kets |*> returns all kets with learn rules.
Here is the python (in the new_context class):
# e is a ket. def list_kets(self,e): label = e.the_label() if len(label) == 0: return ket("",0) if label[-1] != "*": return e label = label.rstrip("*").rstrip(": ") result = superposition() for trial_label in self.ket_rules_dict: if trial_label.startswith(label): result.data.append(ket(trial_label)) return resultI hope that is simple and obvious enough. Should be useful in a bunch of places.
As usual, more to come!
Update: here is a quick example. What is the list of animals with 4 legs?
such-that[has-4-legs] list-kets |animal: *>
Update: For now I have deprecated list-kets. I have replaced it with starts-with.
eg, list of animals with 2 legs?
such-that[has-2-legs] starts-with |animal: >
eg, list all kets that have Fred as a first name?
starts-with |Fred >
eg, list all kets:
starts-with |>
Here is the new python:
# e is a ket. def starts_with(self,e): label = e.the_label() result = superposition() for trial_label in self.ket_rules_dict: if trial_label.startswith(label): result.data.append(ket(trial_label)) return resultThat's it for now. Hrmm... I wonder if I broke any code with this change?
No comments:
Post a Comment