print print 'ツイート検索' print '=' * 20 for text in api.search_tweets('検索')['texts']: print text print print 'リプライ検索' print '=' * 20 for text in api.search_reply('検索')['texts']: print text print print 'マルコフ連鎖' print '=' * 20 seed = {'norm_surface': "今日", 'pos': "名詞"} for morph in api.markov_chain(seed)['morphs']: print morph, # エラーが出る。。 print print '書き換え' print '=' * 20 morphs = ['BOS:BOS', '私:代名詞', 'EOS:EOS'] for morph in api.rewrite_morph('rule_test.txt', morphs)['morphs']: print morph # エラーが出る。。。 print api.tweet('ツイートテスト! ') print api.get_reply()
def markov_based(text): seed = preprocess(text) reply_text = u'' for morph in api.markov_chain(seed)['morphs'][1:-1]: reply_text += u':'.join(morph.split(u':')[:-1])#morph.split(':')[0] return postprocess(reply_text)