def get(self): m = MarkovChains() m.load_db('gquery2') users = m.db.get_users() values = {'users': users} self.response.headers['Content-Type'] = 'text/xml' self.response.out.write(template.render(self.path, values))
def post(self): text = self.request.get('sentences') user = self.request.get('user', default_value=None) m = MarkovChains() m.load_db('gquery2') m.db.store_sentence(text) values = {} self.response.out.write(template.render(self.path, values))
def get(self): m = MarkovChains() m.load_db('gquery2') word = self.request.get('word', default_value=None) text = m.db.fetch_new_sentence() taskqueue.add(url='/task/talk') values = {'text': text} self.response.out.write(template.render(self.path, values))
def get(self): m = MarkovChains() m.load_db('gquery') user = self.request.get('user', default_value=None) if user: chains = m.db.uchain.all() else: chains = m.db.chain.all() values = {'chains': chains} self.response.out.write(template.render(self.path, values))
def get(self): filename = os.path.join('db','sentence_get.xml') path = get_path(filename) m = MarkovChains() m.load_db('gquery2') word = self.request.get('first_word', default_value=None) user = self.request.get('user', default_value=None) text = m.db.fetch_new_sentence() taskqueue.add(url='/task/talk') values = {'text': text} self.response.headers['Content-Type'] = 'text/xml' self.response.out.write(template.render(path, values))
def post(self): if self.request.get('sentences'): text = self.request.get('sentences') m = MarkovChains() m.analyze_sentence(text) word = self.request.get('first_word', default_value=None) result = m.make_sentence(word=word) values = {'result':result} self.response.headers['Content-Type'] = 'text/xml' self.response.out.write(template.render(self.path, values)) else: values = {'result':''} self.response.headers['Content-Type'] = 'text/xml' self.response.out.write(template.render(self.path, values))
def post(self): if self.request.get('sentences'): text = self.request.get('sentences') m = MarkovChains() m.analyze_sentence(text) word = self.request.get('word', default_value=None) result = m.make_sentence(word=word) _chaindic = m.chaindic chaindic = [] for prewords in _chaindic: for postword in _chaindic[prewords]: if _chaindic[prewords][postword].isstart: chaindic.append((prewords[0],prewords[1],postword)) values = {'result':result, 'chaindic':chaindic, 'original':text} self.response.out.write(template.render(self.path, values)) else: values = {'result':''} self.response.out.write(template.render(self.path, values))
def post(self): text = self.request.get('sentences') user = self.request.get('user') m = MarkovChains() m.load_db('gquery2') m.db.store_sentence(text)
def post(self): m = MarkovChains() m.load_db('gquery2') m.db.store_new_sentence()
OAuth の各種キーを読み込む """ parser = SafeConfigParser() parser.readfp(open('config.ini')) sec = 'oauth' consumer_key = parser.get(sec, 'consumer_key') consumer_secret = parser.get(sec, 'consumer_secret') access_token = parser.get(sec, 'access_token') access_token_secret = parser.get(sec, 'access_token_secret') sec = 'twilog' original_id = parser.get(sec, 'original_id') sec = 'bot' tweet_type = int(parser.get(sec, 'tweet_type')) markov = MarkovChains() api = twoauth.api(consumer_key, consumer_secret, access_token, access_token_secret) class DoReply(db.Model): flg = db.BooleanProperty() """ sentence.txt を読み込む """ sentences = []