class GlobalCloneBot(CloneBot): def __init__(self, crawl_user, mecab=None, log_file='crawl.tsv', db_file='bigram.db', crawler_api=None): super(GlobalCloneBot, self).__init__(crawl_user, mecab, log_file, db_file, crawler_api) self.translator = Translator(config.BING_APP_KEY, 'ja', 'en').translator def reply_hook(self, bot, status): """適当にリプライを返してあげる""" if status: text = self.get_text(status.text) bot.reply_to(text, status) else: text = self.get_text() bot.update_status(text) #時々英訳 if random.random()<0.2: text = self.translator.translate(text) bot.update_status(u'[Translated] '+text) #時々再翻訳 if random.random()<0.5: text = self.translator.translate(text, 'en', 'ja') bot.update_status(u'[再翻訳] ' + text) return True
def __init__(self, crawl_user, mecab=None, log_file='crawl.tsv', db_file='bigram.db', crawler_api=None): super(GlobalCloneBot, self).__init__(crawl_user, mecab, log_file, db_file, crawler_api) self.translator = Translator(config.BING_APP_KEY, 'ja', 'en').translator