Пример #1
0
    def give_instructions(self, event):
        # get an object that appears in a least two baskets
        object_, object_baskets = self.get_object_in_many_baskets()
        # choose one of the baskets
        basket = random.choice(object_baskets)
        # ask the learner
        self.set_message("which properties does {object} have "
                         "in {owner}'s basket only?".format(
                             object=object_,
                             owner=basket
                         ))
        # construct the expected answer which is given by the
        # properties of the object in the given basket minus
        # the properties in all the rest of the baskets:
        self.distinctive_properties_set = self.get_expected_answer(
            object_, basket, object_baskets
        )

        # building a regexp to match the answer
        enum_re = delimiters.join(
            [r'([a-z]+)'] * len(self.distinctive_properties_set))
        # final string must be delimited by period
        enum_re += r'\.$'
        # add a handler to match the response
        self.add_handler(on_message(enum_re)(self.check_response))
Пример #2
0
    def give_instructions(self, event):
        # select a random object from a random basket
        basket = random.choice(list(global_properties.keys()))
        object_ = random.choice(list(global_properties[basket].keys()))
        # retrieving the properties of the selected object
        self.object_properties = set(global_properties[basket][object_])

        self.set_message("which properties does {object} have in "
                         "{owner}'s basket?".format(object=object_,
                                                    owner=basket))

        # building a regexp to match the answer
        enum_re = delimiters.join([r'([a-z]+)'] * len(self.object_properties))
        # final string must be delimited by period
        enum_re += r'\.$'
        # add check_response as a handler for a message matching the
        # above described enumeration
        self.add_handler(on_message(enum_re)(self.check_response))
    def give_instructions(self, event):
        # chose a random property
        basket = random.choice(list(rev_global_properties.keys()))
        property_ = random.choice(list(rev_global_properties[basket].keys()))
        # retrieving the objects that have this property
        self.objects = set(rev_global_properties[basket][property_])

        self.set_message("which objects are {property} in "
                         "{owner}'s basket?".format(property=property_,
                                                    owner=basket))

        # building a regexp to match the answer
        enum_re = delimiters.join([r'([a-z]+)'] * len(self.objects))
        # final string must be delimited by period
        enum_re += r'\.$'
        # register a handler that get triggers when an enumeration
        # as described by the regular expression is found.
        self.add_handler(on_message(enum_re)(self.check_response))
    def give_instructions(self, event):
        # select a random object from a random basket
        basket = random.choice(list(global_properties.keys()))
        object_ = random.choice(list(global_properties[basket].keys()))
        # retrieving the properties of the selected object
        self.object_properties = set(global_properties[basket][object_])

        self.set_message("which properties does {object} have in "
                         "{owner}'s basket?".format(
                             object=object_,
                             owner=basket))

        # building a regexp to match the answer
        enum_re = delimiters.join(
            [r'([a-z]+)'] * len(self.object_properties))
        # final string must be delimited by period
        enum_re += r'\.$'
        # add check_response as a handler for a message matching the
        # above described enumeration
        self.add_handler(on_message(enum_re)(self.check_response))
    def give_instructions(self, event):
        object_, property_ = self.get_random_object_property()
        # we find the set of baskets that have the relevant
        # object and property combination
        self.basket_set = set(
            basket for basket, object_properties in global_properties.items()
            if object_ in object_properties
            and property_ in object_properties[object_])
        # at this point, if baskets list is empty we add "nobody" as
        # the only item in it
        if not self.basket_set:
            self.basket_set.add('nobody')

        self.set_message("who has {property_object} in the basket?".format(
            property_object=msg.indef_article(property_ + " " + object_)))

        # building a regexp to match the answer
        enum_re = delimiters.join([r'([a-z]+)'] * len(self.basket_set))
        # final string must be delimited by period
        enum_re += r'\.$'
        # add a handler to match the response
        self.add_handler(on_message(enum_re)(self.check_response))