43
31

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.

【Python】漢字をひらがなに変換する

Last updated at Posted at 2018-11-28

#使用しているライブラリ「Pykakasi」
miurahr/pykakasi: pykakasi is re-imprelemtation of kakasi library in Python.

##漢字をひらがなに変換するコード

from pykakasi import kakasi

text = "形態素解析"

# オブジェクトをインスタンス化
kakasi = kakasi()
# モードの設定:J(Kanji) to H(Hiragana)
kakasi.setMode('J', 'H') 

# 変換して出力
conv = kakasi.getConverter()
conv.do(text)  # => けいたいそかいせき

##Options

Option Description Values Note
K Katakana convertion a,H,None roman, Hiragana or noconversion
H Hiragana convertion a,K,None roman, Katakana or noconversion
J Kanji conversion a,H,K,None roman or Hiragana, Katakana or noconv
a Roman conversion E,None JIS ROMAN or noconversion
E JIS ROMAN conversion a,None ascii roman or noconversion
43
31
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
43
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?