challenge_micro.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:Round1 作者: general-ai-challenge 项目源码 文件源码
def get_task_generator(self):
        content = load_dictionary(DICTIONARY_FILE)
        vocabulary = content[:200]
        mapping = dict(zip(random.sample(vocabulary, self.MAPPING_SIZE),
                           random.sample(vocabulary, self.MAPPING_SIZE)))
        keys = list(mapping.keys())
        self.mapping_check = {key: False for key in keys}

        def micro6_question(self):
            def micro6_feedback(is_correct, question):
                reaction = "good job" if is_correct else "wrong"
                if not is_correct:
                    return reaction + '! ' + sentence
                else:
                    return reaction + '! '
            self.key_idx = random.randint(0, len(keys) - 1)
            word1 = keys[self.key_idx]
            word2 = mapping[word1]
            question = 'random_map: ' + word1 + '.'
            sentence = word2 + '.'
            return question, [sentence], micro6_feedback

        return TaskGenerator(micro6_question, '', None, ';')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号