1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

漢字をカナに変換する

Posted at

##mecabを使って、カナ変換し結果をつなげて一つの文字列にして出力する

import MeCab

def mecab_list(text):
    tagger = MeCab.Tagger("-Ochasen")
    tagger.parse('')
    node = tagger.parseToNode(text)
    word_class = []
    while node:
        word = node.surface
        wclass = node.feature.split(',')
        if wclass[0] != u'BOS/EOS':
            if wclass[6] == None:
                word_class.append((wclass[7]))
            else:
                word_class.append((wclass[7]))
        node = node.next
    mojiretsu=''.join(word_class) 
    return mojiretsu

#参考
Python 、Mecab、GoogleTranslitrateAPIで漢字→カタカナ→ひらがな→漢字変換をする。
PythonでMeCabの出力をリスト化するモジュール(mecab-python)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?