예제 #1
0
def postprocess(sent):
    morphs = api.morph(sent)['morphs']
    query = list()
    for morph in morphs:
        query.append(u'{}:{}'.format(morph['norm_surface'], morph['pos']))
    morphs = api.rewrite_morph(rewrite_rule, query)['morphs']
    sent = u''
    for morph in morphs[1:-1]:
        sent += u':'.join(morph.split(u':')[:-1])
    return sent
예제 #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()