Пример #1
0
        print reply_text1
        api.send_reply(mention_id, user_name, 'tw:' + reply_text1)
    else:
        print reply_text2
        api.send_reply(mention_id, user_name, 'mv:' + reply_text2)


if __name__ == '__main__':
    args = docopt(__doc__)
    api = get_api()
    logging.config.fileConfig('logging.conf')
    logger = logging.getLogger(__name__)
    
    try:
        # メンションの取得
        result = api.get_reply()
        current_state = result['grade']
        replies = result['replies']
        rewrite_rule = u'4_rewrite_grade{}.txt'.format(current_state)
        scenario_file = u'4_scenario_grade{}.txt'.format(current_state)
    #    rewrite_rule = 'rewrite_c00.txt'
    #    query = ['BOS:BOS', '私:代名詞', 'EOS:EOS']
    #    print api.rewrite_morph(rewrite_rule, query, True).text

        if args['--term']:
            print 'chatbot on this terminal'
            print 'input your message'
            for line in iter(sys.stdin.readline, '\n'):
                if args['--all']:
                    for i in range(3):
                        rewrite_rule = u'4_rewrite_grade{}.txt'.format(i)
Пример #2
0
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()
Пример #3
0
    if args["--dev"]:
        url = "https://52.68.75.108"
        usr = "******"
        paswd = "js2015cps"
    else:
        url = "http://10.243.251.70"
        usr = None
        paswd = None

    return api.API(url, usr, paswd)


if __name__ == "__main__":
    api = get_api()

    reps = api.get_reply()
    print json.dumps(reps, ensure_ascii=False, indent=4)

    for rep in reps["replies"]:
        print "======================================================"
        if reps["grade"] == 0:
            scenario_file = "scenario_c09.txt"
        elif reps["grade"] == 1:
            scenario_file = "scenario_c09.txt"
        else:
            scenario_file = "scenario_c09.txt"
        sent = api.sentences(rep["text"])
        text = []
        for s in sent["sentences"]:
            print "-------------------------------------------------------"
            print s