Exemplo n.º 1
0
def twitter_based(text):
    seed = generate_seed(text)
    # TODO とりあえずツイート検索結果の最初のツイートを利用
    tweet_example = api.search_tweets(seed['norm_surface'], limit=1)
    # 空ならNoneを返す
    if tweet_example['count'] == 0:
        return None
    # TODO とりあえず先頭の文を利用
    # 形態素列書き換え
    sent = api.sentences(tweet_example['texts'][0])['sentences'][0]
    return postprocess(sent)
Exemplo n.º 2
0
import api

api = api.API('https://52.68.75.108', 'secret', 'js2015cps')

print
print '文分割'
s = '日本語文字列を文単位で分割する。複数文を渡すと、文ごとに区切ってくれる。'
for sentence in  api.sentences(s)['sentences']:
    print sentence


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,