Formal Model for Kana-Kanji Conversion (KKC) In Japanese input, users type in phonetic Hiragana, but proper Japanese is written in logographic Kanji K

Similar documents
NLP プログラミング勉強会 6 かな漢字変換 自然言語処理プログラミング勉強会 6 - かな漢字変換 Graham Neubig 奈良先端科学技術大学院大学 (NAIST) 1

NLP プログラミング勉強会 5 HMM による品詞推定 自然言語処理プログラミング勉強会 5 隠れマルコフモデルによる品詞推定 Graham Neubig 奈良先端科学技術大学院大学 (NAIST) 1

NLP プログラミング勉強会 4 単語分割 自然言語処理プログラミング勉強会 4 - 単語分割 Graham Neubig 奈良先端科学技術大学院大学 (NAIST) 1

L1 What Can You Blood Type Tell Us? Part 1 Can you guess/ my blood type? Well,/ you re very serious person/ so/ I think/ your blood type is A. Wow!/ G

言語モデルの基礎 2

25 II :30 16:00 (1),. Do not open this problem booklet until the start of the examination is announced. (2) 3.. Answer the following 3 proble

はじめに

open / window / I / shall / the? something / want / drink / I / to the way / you / tell / the library / would / to / me




西川町広報誌NETWORKにしかわ2011年1月号

P


-2-

高等学校 英語科

What s your name? Help me carry the baggage, please. politeness What s your name? Help me carry the baggage, please. iii

Hospitality-mae.indd

2

\615L\625\761\621\745\615\750\617\743\623\6075\614\616\615\606.PS

-2-

AtCoder Regular Contest 073 Editorial Kohei Morita(yosupo) A: Shiritori if python3 a, b, c = input().split() if a[len(a)-1] == b[0] and b[len(

GOT7 EYES ON YOU ミニアルバム 1. ノハナマン What? I think it s stuck ノマンイッスミョンデェヌンゴヤ Yeah モドゥンゴルジュゴシポソ Yo baby ノワオディトゥンジカゴシポ everywhere ナンニガウォナンダミョンジュゴシポ anythin

Motivation and Purpose There is no definition about whether seatbelt anchorage should be fixed or not. We tested the same test conditions except for t

soturon.dvi


< D8291BA2E706466>

目次 1. レッスンで使える表現 レッスンでお困りの際に使えるフレーズからレッスンの中でよく使われるフレーズまで 便利な表現をご紹介させていただきます ご活用方法として 講師に伝えたいことが伝わらない場合に下記の通りご利用ください 1 該当の表現を直接講師に伝える 2 該当の英語表現を Skype

日本語教育紀要 7/pdf用 表紙



国際恋愛で避けるべき7つの失敗と解決策

第16回ニュージェネレーション_cs4.indd


1 ( 8:12) Eccles. 1:8 2 2

Microsoft Word - j201drills27.doc

NO

P

fx-9860G Manager PLUS_J

C. S2 X D. E.. (1) X S1 10 S2 X+S1 3 X+S S1S2 X+S1+S2 X S1 X+S S X+S2 X A. S1 2 a. b. c. d. e. 2

浜松医科大学紀要

DT pdf

鹿大広報149号

日本看護管理学会誌15-2

¥ì¥·¥Ô¤Î¸À¸ì½èÍý¤Î¸½¾õ

第4回 JISSスポーツ科学会議 ポスターセッション

平成29年度英語力調査結果(中学3年生)の概要

第17回勉強会「英語の教え方教室」報告

Page 1 of 6 B (The World of Mathematics) November 20, 2006 Final Exam 2006 Division: ID#: Name: 1. p, q, r (Let p, q, r are propositions. ) (10pts) (a

STEP 02 Memo: Self-Introduction Self-Introduction About your family About your school life (your classes, club/juku, and so on.) Questions to your Pen

:. * ** *** **** Little Lord Fauntleroy Little Lord Fauntleroy Frances Eliza Hodgson Burnett, - The Differences between the Initial Edition and First

Introduction to Information and Communication Technology (a)

Answers Practice 08 JFD1


L3 Japanese (90570) 2008

LC304_manual.ai

Microsoft Word - j201drills27.doc

CA HP,,,,,,.,,,,,,.,,,,,,.,,,,,,.,,,,,,.,,,,,,.,,,,,,.,,,,,.,,,,,.,,,,,.,,,,,.,,,,,.,,,,,.,,,,,.,,,,,.,,,,,,.,,,,,.,,,,,,.,,,,,.,,,,,.,,,,,,.,,,,,,.,,

178 New Horizon English Course 28 : NH 3 1. NH 1 p ALT HP NH 2 Unit 2 p. 18 : Hi, Deepa. What are your plans for the holidays? I m going to visi

The Way We Are no TJF 5 5 TJF

tikeya[at]shoin.ac.jp The Function of Quotation Form -tte as Sentence-final Particle Tomoko IKEYA Kobe Shoin Women s University Institute of Linguisti

教育実践上の諸問題


Level 3 Japanese (90570) 2011

AERA_English_CP_Sample_org.pdf

月額36万円レポート


きずなプロジェクト-表紙.indd

126 学習院大学人文科学論集 ⅩⅩⅡ(2013) 1 2

Vol. 43 No. 2 Feb. 2002,, MIDI A Probabilistic-model-based Quantization Method for Estimating the Position of Onset Time in a Score Masatoshi Hamanaka

作業手順手引き

Read the following text messages. Study the names carefully. 次のメッセージを読みましょう 名前をしっかり覚えましょう Dear Jenny, Iʼm Kim Garcia. Iʼm your new classmate. These ar

elemmay09.pub

/ [Save & Submit Code]ボタン が 下 部 やや 左 に ありますが このボタンを 押 すと 右 上 の 小 さいウィンドウ(the results tab) が 本 物 のブラウザのようにアク ションします (ブラウザの 例 : Chrome(グーグルクロム) Firefox(

gengo.dvi

...

28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment

untitled

1 Fig. 1 Extraction of motion,.,,, 4,,, 3., 1, 2. 2.,. CHLAC,. 2.1,. (256 ).,., CHLAC. CHLAC, HLAC. 2.3 (HLAC ) r,.,. HLAC. N. 2 HLAC Fig. 2

80 X 1, X 2,, X n ( λ ) λ P(X = x) = f (x; λ) = λx e λ, x = 0, 1, 2, x! l(λ) = n f (x i ; λ) = i=1 i=1 n λ x i e λ i=1 x i! = λ n i=1 x i e nλ n i=1 x

untitled

駒田朋子.indd

Mimehand II[1] [2] 1 Suzuki [3] [3] [4] (1) (2) 1 [5] (3) 50 (4) 指文字, 3% (25 個 ) 漢字手話 + 指文字, 10% (80 個 ) 漢字手話, 43% (357 個 ) 地名 漢字手話 + 指文字, 21

1 2 3


Fig. 1 Photography of exercise test by Arm Crank Ergometer. Fig. 2 Photography of exercise test by chair with caster. Arm Crank Ergometer Wheelchair T

S1Šû‘KŒâ‚è

ポイント 1 文型の意義? The ship made for the shore. She made a good wife. I will make a cake for her birthday. make (SVC) (SVO) S V X = [ ] 5



先 週 の 復 習 : 文 の 確 率 計 算 文 の 確 率 が 欲 しい W = speech recognition system 変 数 で 以 下 のように 表 す ( 連 鎖 の 法 則 を 用 いて ): P( W = 3, w 1 = speech, w 2 = recognitio


000-Tanikawa_Watanabe

h23w1.dvi

Ver.1 1/17/2003 2

Kyushu Communication Studies 第2号

22 1,936, ,115, , , , , , ,


1986 NHK NTT NTT CONTENTS SNS School of Information and Communi

EQUIVALENT TRANSFORMATION TECHNIQUE FOR ISLANDING DETECTION METHODS OF SYNCHRONOUS GENERATOR -REACTIVE POWER PERTURBATION METHODS USING AVR OR SVC- Ju

Transcription:

NLP Programming Tutorial 6 - Kana-Kanji Conversion Graham Neubig Nara Institute of Science and Technology (NAIST) 1

Formal Model for Kana-Kanji Conversion (KKC) In Japanese input, users type in phonetic Hiragana, but proper Japanese is written in logographic Kanji Kana-Kanji Conversion: Given an unsegmented Hiragana string X, predict its Kanji string Y かなかんじへんかんはにほんごにゅうりょくのいちぶ かな漢字変換は日本語入力の一部 Also a type of structured prediction, like HMMs or word segmentation 2

There are Many Choices! かなかんじへんかんはにほんごにゅうりょくのいちぶ かな漢字変換は日本語入力の一部仮名漢字変換は日本語入力の一部 かな漢字変換は二本後入力の一部家中ん事変感歯にホン御乳力の胃治舞 good! good? bad?!?!... How does the computer tell between good and bad? Probability model! argmax Y P (Y X ) 3

Remember (from the HMM): Generative Sequence Model Decompose probability using Bayes' law argmax Y P (Y X )=argmax Y =argmax Y P (X Y ) P(Y ) P (X ) P (X Y ) P(Y ) Model of Kana/Kanji interactions かんじ is probably 感じ Model of Kanji-Kanji interactions 漢字 comes after かな 4

Sequence Model for Kana-Kanji Conversion Kanji Kanji language model probabilities I +1 Bigram model P (Y ) i=1 P LM ( y i y i 1 ) Kanji Kana translation model probabilities I P (X Y ) 1 P TM ( x i y i ) P LM ( 漢字 かな ) P LM ( かな <s>) P LM ( 変換 漢字 ) <s> かな漢字変換は日本語... </s> かなかんじへんかんはにほんご P TM ( かな かな ) * P TM ( かんじ 漢字 ) * P TM ( へんかん 変換 ) 5

Generative Sequence Model Emission/Translation Probability Wait! I heard this last week!!! Transition/Language Model Probability Structured Prediction 6

Differences between POS and Kana-Kanji Conversion 1. Sparsity of P(y i y i-1 ): HMM: POS POS is not sparse no smoothing KKC: Word Word is sparse need smoothing 2. Emission possibilities HMM: Considers all word-pos combinations KKC: Considers only previously seen combinations 3. Word segmentation: HMM: 1 word, 1 POS tag KKC: Multiple Hiragana, multiple Kanji 7

1. Handling Sparsity Simple! Just use a smoothed bi-gram model Bigram: Unigram: P( y i y i 1 )=λ 2 P ML ( y i y i 1 )+(1 λ 2 ) P( y i ) P( y i )=λ 1 P ML ( y i )+(1 λ 1 ) 1 N Re-use your code from Tutorial 2 8

2. Translation possibilities For translation probabilities, use maximum likelihood P TM ( x i y i )=c( y i x i )/c( y i ) Re-use your code from Tutorial 5 Implication: We only need to consider some words c( 感じ かんじ ) = 5 c( 漢字 かんじ ) = 3 c( 幹事 かんじ ) = 2 c( トマト X かんじ ) = 0 c( 奈良 かんじ ) = 0 c( 監事 かんじ ) = 0... Efficient search is possible 9

3. Words and Kana-Kanji Conversion Easier to think of Kana-Kanji conversion using words かなかんじへんかんはにほんごにゅうりょくのいちぶ かな漢字変換は日本語入力の一部 We need to do two things: Separate Hiragana into words Convert Hiragana words into Kanji We will do these at the same time with the Viterbi algorithm 10

Search for Kana-Kanji Conversion I'm back! 11

Search for Kana-Kanji Conversion Use the Viterbi Algorithm What does our graph look like? 12

Search for Kana-Kanji Conversion Use the Viterbi Algorithm かなかんじへんかん 0:<S> 1: 書 2: 無 1: 化 1: か 1: 下 2: な 2: 名 2: 成 2: かな 2: 仮名 3: 中 3: 書 3: 化 3: か 3: 下 4: 管 4: 感 4: ん 5: じ 5: 感じ 5: 漢字 5: 時 6: へ 6: 減 6: 経 7: 変 7: ん 8: 変化 9: 変換 8: 書 8: 化 8: か 8: 下 9: 管 9: 感 9: ん 10:</S> 13

Search for Kana-Kanji Conversion Use the Viterbi Algorithm かなかんじへんかん 0:<S> 1: 書 2: 無 1: 化 1: か 1: 下 2: かな 2: 仮名 2: な 2: 名 2: 成 3: 中 3: 書 3: 化 3: か 3: 下 4: 管 4: 感 4: ん 5: じ 5: 感じ 5: 漢字 5: 時 6: へ 6: 減 6: 経 7: 変 7: ん 8: 変化 8: 書 8: 化 8: か 8: 下 9: 変換 9: 管 9: 感 9: ん 10:</S> 14

Steps for Viterbi Algorithm First, start at 0:<S> かなかんじへんかん 0:<S> S[ 0:<S> ] = 0 15

0:<S> Search for Kana-Kanji Conversion Expand 0 1, with all previous states ending at 0 かなかんじへんかん 1: 書 1: 化 1: か 1: 下 S[ 1: 書 ] = -log (P TM ( か 書 ) * P LM ( 書 <S>)) + S[ 0:<S> ] S[ 1: 化 ] = -log (P TM ( か 化 ) * P LM ( 化 <S>)) + S[ 0:<S> ] S[ 1: か ] = -log (P TM ( か か ) * P LM ( か <S>)) + S[ 0:<S> ] S[ 1: 下 ] = -log (P TM ( か 下 ) * P LM ( 下 <S>)) + S[ 0:<S> ] 16

0:<S> Search for Kana-Kanji Conversion Expand 0 2, with all previous states ending at 0 かなかんじへんかん 1: 書 1: 化 1: か 1: 下 2: かな 2: 仮名 S[ 1: かな ] = -log (P E ( かな かな ) * P LM ( かな <S>)) + S[ 0:<S> ] S[ 1: 仮名 ] = -log (P E ( かな 仮名 ) * P LM ( 仮名 <S>)) + S[ 0:<S> ] 17

Search for Kana-Kanji Conversion Expand 1 2, with all previous states ending at 1 かなかんじへんかん 0:<S> 1: 書 2: 無 1: 化 1: か 1: 下 2: な 2: 名 2: 成 2: かな 2: 仮名 S[ 2: 無 ] = min( -log (P E ( な 無 ) * P LM ( 無 書 )) + S[ 1: -log (P E ( な 無 ) * P LM ( 無 化 )) + S[ 1: -log (P E ( な 無 ) * P LM ( 無 か )) + S[ 1: -log (P E ( な 無 ) * P LM ( 無 下 )) + S[ 1: S[ 2: な ] = min( 書 ], 化 ], か ], 下 ] ) 書 ], 化 ], か ], 下 ] ) -log (P E ( な な ) * P LM ( な 書 )) + S[ 1: -log (P E ( な な ) * P LM ( な 化 )) + S[ 1: -log (P E ( な な ) * P LM ( な か )) + S[ 1: -log (P E ( な な ) * P LM ( な 下 )) + S[ 1: 18

Algorithm 19

Overall Algorithm load lm # Same as tutorials 2 load tm # Similar to tutorial 5 # Structure is tm[pron][word] = prob for each line in file do forward step do backward step # Same as tutorial 5 print results # Same as tutorial 5 20

Implementation: Forward Step edge[0][ <s> ] = NULL, score[0][ <s> ] = 0 for end in 1.. len(line) # For each ending point create map my_edges for begin in 0.. end 1 # For each beginning point pron = substring of line from begin to end # Find the hiragana my_tm = tm_probs[pron] # Find words/tm probs for pron if there are no candidates and len(pron) == 1 my_tm = (pron, 0) # Map hiragana as-is for curr_word, tm_prob in my_tm # For possible current words for prev_word, prev_score in score[begin] # For all previous words/probs # Find the current score curr_score = prev_score + -log(tm_prob * P LM (curr_word prev_word)) if curr_score is better than score[end][curr_word] score[end][curr_word] = curr_score edge[end][curr_word] = (begin, prev_word) 21

Exercise 22

Exercise Write kkc.py and re-use train-bigram.py, train-hmm.py Test the program train bigram.py test/06 word.txt > lm.txt train hmm.py test/06 pronword.txt > tm.txt kkc.py lm.txt tm.txt test/06 pron.txt > output.txt Answer: test/06 pronword.txt 23

Exercise Run the program train bigram.py data/wiki ja train.word > lm.txt train hmm.py data/wiki ja train.pronword > tm.txt kkc.py lm.txt tm.txt data/wiki ja test.pron > output.txt Measure the accuracy of your tagging with 06 kkc/gradekkc.pl data/wiki ja test.word output.txt Report the accuracy (F-meas) Challenge: Find a larger corpus or dictionary, run KyTea to get the pronunciations, and train a better model 24

Thank You! 25