Slide 1

Slide 1 text

೔ຊޠೖྗͰ͖Δ ΩʔϘʔυΞϓϦΛ࡞Ζ͏ʂ iOSDC Japan 2023 iOSͷKeyboard ExtensionͰ೔ຊޠIME։ൃʹೖ໳

Slide 2

Slide 2 text

azooKey • ೔ຊޠೖྗػೳ • ͔ͳ׽ࣈม׵ • ༧ଌม׵ • ֆจࣈɾه߸ྨͷೖྗ • Ϣʔβࣙॻ • ֶश • ޡΓగਖ਼ • ΩʔϘʔυΞϓϦػೳ • ணͤସ͑ • ϥΠϒม׵ • ΧελϜΩʔ • ΧελϜλϒ • ίϐʔཤྺอଘ • छʑͷઃఆ https://github.com/ensan-hcl/azooKey OSSʂ

Slide 3

Slide 3 text

࿩͢͜ͱ • ΩʔϘʔυΞϓϦͷ֓ཁ • ೔ຊޠೖྗ • ࢓૊Έ • ࡞ͬͯΈΑ͏ • ύοέʔδͷ঺հ • ࣙॻ • ΩʔϘʔυͷUIʢͷਏ͍ͱ͜Ζʣ • ·ͱΊ

Slide 4

Slide 4 text

ΩʔϘʔυΞϓϦ

Slide 5

Slide 5 text

ΩʔϘʔυΞϓϦ = Keyboard Extension • ඪ४ΩʔϘʔυͱಉ༷ʹར༻Ͱ͖Δ • γεςϜͷ΄ͱΜͲͲ͜Ͱ΋ಈ͘ • ػೳ໘͸੍໿ڧΊ • ϓϥΠόγʔ • Ϧιʔε • ίϯςφΞϓϦʹಉࠝͯ͠഑෍͢Δ • ೔ຊޠೖྗରԠͷΞϓϦ͸গͳ͍

Slide 6

Slide 6 text

೔ຊޠೖྗΞϓϦ • ίϯςφΞϓϦΛ࡞ΔʢઃఆɾνϡʔτϦΞϧʣ • ΩʔϘʔυͷΠϯλʔϑΣʔεΛ࡞Δ • ೔ຊޠೖྗΤϯδϯΛ࡞Δʢ͕͜͜ຊؙʣ • ม׵ΤϯδϯΛ࣮૷͢Δ • ࣙॻ΋࡞Δ

Slide 7

Slide 7 text

೔ຊޠೖྗ

Slide 8

Slide 8 text

೔ຊޠೖྗ͍Ζ͍Ζ • ͍ΘΏΔʮ͔ͳ׽ࣈม׵ʯʢͻΒ͕ͳΛͨ͘͞Μଧͬͯม׵͢Δ΍ͭʣ • ଟ͘ͷ؀ڥͰσϑΥϧτͷ೔ຊޠೖྗํ๏ • ࠓճ͸͜ΕΛओʹѻ͍·͢ • SKKʢSimple Kana to Kanji conversion programʣ • iOSʹ΋FlickSKKɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ͕͋Γ·͢ • ׽ࣈ௚઀ೖྗ • ׽ࣈΛ௚઀ೖྗ͢Δํࣜɺෳࡶͳม׵ΤϯδϯཁΒͣ https://github.com/codefirst/FlickSKK

Slide 9

Slide 9 text

๲େͳީิ • Ұͭͷೖྗʹରͯ͠ɺ ͨ͘͞Μͷީิ͕ߟ͑ ΒΕΔ • ؒʹ߹͍ͦ͏Ͱ͢ • ਅʹѪ૝࿹૥ • ϚχΞҠૹDeath ೖྗɿ·ʹ͍͋ͦ͏Ͱ͢ ຐ Ҡૹ ؒʹ߹͍ ͦ͏ Ͱ͢ ډ ʹ ਅ ձ͍ ү Ѫ૝ ૯ग़ ࿹ ϚχΞ %FBUI ૥

Slide 10

Slide 10 text

๲େͳީิ • Ұͭͷೖྗʹରͯ͠ɺ ͨ͘͞Μͷީิ͕ߟ͑ ΒΕΔ • ؒʹ߹͍ͦ͏Ͱ͢ • ਅʹѪ૝࿹૥ • ϚχΞҠૹDeath ೖྗɿ·ʹ͍͋ͦ͏Ͱ͢ ຐ Ҡૹ ؒʹ߹͍ ͦ͏ Ͱ͢ ډ ʹ ਅ ձ͍ ү Ѫ૝ ૯ग़ ࿹ ϚχΞ %FBUI ૥

Slide 11

Slide 11 text

๲େͳީิ • Ұͭͷೖྗʹରͯ͠ɺ ͨ͘͞Μͷީิ͕ߟ͑ ΒΕΔ • ؒʹ߹͍ͦ͏Ͱ͢ • ਅʹѪ૝࿹૥ • ϚχΞҠૹDeath ೖྗɿ·ʹ͍͋ͦ͏Ͱ͢ ຐ Ҡૹ ؒʹ߹͍ ͦ͏ Ͱ͢ ډ ʹ ਅ ձ͍ ү Ѫ૝ ૯ग़ ࿹ ϚχΞ %FBUI ૥

Slide 12

Slide 12 text

͔ͳ׽ࣈม׵ • ม׵ΞϧΰϦζϜ • ୯ޠͷ1-gramͱ඼ࢺͷ2-gramΛ࢖͏ ≒ʮ୯ޠ1ͭ͋ͨΓͷείΞ + 2ͭฒΜͩ඼ࢺͷϖΞͷείΞʯΛ࠷େԽ • ࣙॻσʔλ • ܗଶૉղੳ༻ࣙॻΛϕʔεʹࣗ࡞͠·͢

Slide 13

Slide 13 text

είΞͷߟ͑ํ • ͔ͳྻʹର͢ΔՄೳͳ׽ࣈม׵ީิ͕େྔʹ͋Δ • ͨ͘͞Μͷ݁ՌΛධՁͯ͠ɺॱҐ෇͚͍ͨ͠ →֤݁ՌͷʮείΞʯΛܭࢉ • සൟʹग़ͯ͘Δ୯ޠͷ༏ઌॱҐΛ্͍͛ͨ →୯ޠͷग़ݱ֬཰͕ߴ͍ީิʹྑ͍είΞΛ༩͑Δ • จ๏΋গ͠ߟྀ͍ͨ͠ →2ͭฒΜͩ඼ࢺͷϖΞͷग़ݱ֬཰͕ߴ͍ީิʹ ྑ͍είΞΛ༩͑Δ

Slide 14

Slide 14 text

୯ޠͷείΞʢؾ࣋ͪʣ ࢥ͏ ͓ໟ ૝͏ Ա͏ ʮࢥ͏ʯͷස౓͕ߴ͍ͷͰɺʮ͓΋͏ʯͷม׵Ͱ͸ʮࢥ͏ʯΛ༏ઌ

Slide 15

Slide 15 text

඼ࢺͷϖΞͷείΞʢؾ࣋ͪʣ ݴ༿Λ ॿࢺϮ ࿩͢ ಈࢺ ͸՘ࢠ ॿࢺϋʴ໊ࢺ ʮॿࢺϮʯͷ͋ͱʹʮॿࢺϋʯ͸དྷʹ͍͘ͷͰ͜ͷม׵Ͱ͸ʮ࿩͢ʯΛ༏ઌ

Slide 16

Slide 16 text

࣮ࡍͷܭࢉ ຐ Ҡૹ ؒʹ߹͍ ͦ͏ Ͱ͢ ډ ʹ ਅ ձ͍ ү Ѫ૝ ૯ग़ ࿹ ϚχΞ %FBUI ૥ • ީิ͸ͨ͘͞Μ͋Δ • είΞ͕࠷େʹͳΔ Α͏ͳީิΛ୳ࡧ • ݟ͚ͭΒΕΔͳΒํ๏ ͸ͳΜͰ΋͍͍ ೖྗɿ·ʹ͍͋ͦ͏Ͱ͢

Slide 17

Slide 17 text

࣮ࡍͷܭࢉ • ޮ཰Α͘ܭࢉ͢ΔͨΊ ʮViterbiΞϧΰϦζϜʯ ͕࢖͑Δɻ • ಈతܭը๏ͷҰछ ೖྗɿ·ʹ͍͋ͦ͏Ͱ͢ ຐ Ҡૹ ؒʹ߹͍ ͦ͏ Ͱ͢ ډ ʹ ਅ ձ͍ ү Ѫ૝ ૯ग़ ࿹ ϚχΞ %FBUI ૥

Slide 18

Slide 18 text

࡞ͬͯΈΑ͏

Slide 19

Slide 19 text

ϑϧ࣮૷ʢ170ߦʣ https://github.com/ensan-hcl/KanaKanjiConversionSamples ensan-hcl/KanaKanjiConversionSamples

Slide 20

Slide 20 text

࣮૷ʢWordʣ

Slide 21

Slide 21 text

࣮૷ʢNodeʣ

Slide 22

Slide 22 text

ࣙॻʢఆٛͷΈʣ

Slide 23

Slide 23 text

ม׵ثʢఆٛͷΈʣ

Slide 24

Slide 24 text

ม׵ث①

Slide 25

Slide 25 text

ม׵ث②

Slide 26

Slide 26 text

ม׵ث③

Slide 27

Slide 27 text

ม׵ث④

Slide 28

Slide 28 text

׬੒ʂ

Slide 29

Slide 29 text

࣮༻͢Δʹ͸ʁ • ෳ਺ͷީิʢN-BestղʣΛఏҊͰ͖ΔΑ͏ʹ͢Δ • จઅ෼ׂɺ෦෼ม׵ɺ༧ଌม׵ͳͲΛαϙʔτ͢Δ • ม׵ͷߴ଎Խ • ΩϟογϡΛར༻ͯ͠෦෼తͳมߋʹରͯ͠ߴ଎ͳॲཧΛߦ͏ • ଥ౰Ͱ͸ͳ͍ީิΛͳΔ΂͘ૣ͘ʹࣺͯΔ • ࣙॻҾ͖ͷߴ଎ԽɾলϝϞϦԽ • LOUDS Trieͱ͍͏σʔλߏ଄͕໾ཱͭʢଞʹ΋͍ΖΜͳѹॖख๏͕͋Δʣ

Slide 30

Slide 30 text

AzooKeyKanaKanjiConverter • ࣮૷ࡁΈͷ͔ͳ׽ࣈม׵ύοέʔδ • https://github.com/ensan-hcl/ AzooKeyKanaKanjiConverter • SwiftPMͰϓϩδΣΫτʹ௥ՃͰ͖·͢ • ࣙॻʢ഑෍͋ΓʣΛೖΕΕ͹਺ߦͷ ίʔυͰ͔ͳ׽ࣈม׵Ͱ͖·͢

Slide 31

Slide 31 text

ࣙॻ

Slide 32

Slide 32 text

ࣙॻʹඞཁͳ΋ͷ • ͜Μͳײ͡ͷσʔλ͕ཉ͍͠ • ୯ޠͷಡΈɿΘ͍͕ͤͩͩ͘ • ୯ޠͷදهɿૣҴాେֶ • ୯ޠͷ඼ࢺɿݻ༗໊ࢺ • ୯ޠͷείΞɿ10 • ඼ࢺͷϖΞͷείΞ

Slide 33

Slide 33 text

ࣙॻʹඞཁͳ΋ͷ • ͜Μͳײ͡Ͱ४උͰ͖Δ • ୯ޠͷಡΈ→ܗଶૉղੳ༻ͷࣙॻ͔ΒऔΔ • ୯ޠͷදه→ܗଶૉղੳ༻ͷࣙॻ͔ΒऔΔ • ୯ޠͷ඼ࢺ→ܗଶૉղੳ༻ͷࣙॻ͔ΒऔΔ • ୯ޠͷείΞ→Θ͔Βͳ͍ • ඼ࢺͷϖΞͷείΞ→Θ͔Βͳ͍

Slide 34

Slide 34 text

ࣙॻʹඞཁͳ΋ͷɿස౓ͷ৘ใ • είΞͷܭࢉ • ࣮ࡍͷݴޠσʔλΛܗଶૉղੳ • ස౓ͷ৘ใΛ༻͍ͯείΞΛܾఆ • ࣙॻΛੜ੒͢Δ

Slide 35

Slide 35 text

ࣙॻͷվળɿ௥ՃͰ΍Δ͜ͱ • ෳ߹ޠͷੜ੒ɿස౓ͷߴ͍ෳ߹ޠΛҰޠͱͯࣙ͠ॻొ࿥͢Δ • ܗଶૉղੳ༻ࣙॻͷੜ੒ɿΑΓਫ਼౓ͷߴ͍ղੳΛߦ͏ͨΊɺܗଶૉղੳ༻ࣙ ॻΛࣗલͰੜ੒ • ਓ໊ࣙॻͷੜ੒ɿ࠷৽ͷਓ໊Λαϙʔτ͢ΔͨΊɺ༗໊ਓͷσʔλΛ࡞Δ • ಉදهҟಡޠͷௐ੔ɿʮ೔ຊʢχοϙϯɾχϗϯʣʯͷΑ͏ͳಉදهҟಡޠ ͷείΞௐ੔Λߦ͏ • ௥Ճޠኮɿه߸ͳͲɺࣙॻ΁ͷ௥ՃޠኮΛखಈͰ४උ

Slide 36

Slide 36 text

ࣙॻσʔλͷ഑෍ • azooKeyͷࣙॻσʔλΛ഑෍͍ͯ͠·͢ • ϏϧυࡁΈόΠφϦ • ੜCSVσʔλ • azooKeyͷREADMEʹϦϯΫ͕͋Γ·͢ • Apache License Version 2.0Ͱ͢

Slide 37

Slide 37 text

ΩʔϘʔυͷUIʢͷਏ͍ͱ͜ʣ

Slide 38

Slide 38 text

ೖྗঢ়ଶ؅ཧ • Ϣʔβ͸ΩʔϘʔυΛܦ༝ͤͣʹςΩετΛૢ࡞Ͱ͖Δ • ςΩετͷબ୒ • ΧʔιϧҠಈ • ϖʔετ • ͜ΕΒΛద੾ʹݕ஌ͯ͠ॲཧ͠ͳ͍ͱɺϢʔβʹݟ͍͑ͯΔը໘ͱ ΩʔϘʔυͷ಺෦ঢ়ଶ͕ζϨͯ͠·͏ • ΩʔϘʔυΛܦ༝͠ͳ͍ૢ࡞ʹରԠͨ͠ೖྗঢ়ଶͷ؅ཧ͕ඞཁ

Slide 39

Slide 39 text

ೖྗঢ়ଶ؅ཧɿಓ۩ • Keyboard Extension͕औΕΔͷ͸ ҎԼͷ3ͭͷΈ • Χʔιϧલͷจࣈྻ: var documentContextBeforeInput: String? • બ୒͍ͯ͠Δจࣈྻ: var selectedText: String? • Χʔιϧޙͷจࣈྻ: var documentContextAfterInput: String? • Keyboard Extension͕Ͱ͖Δͷ͸ ҎԼͷ3ͭͷΈʢ˞ʣ • ΧʔιϧҐஔ΁ͷจࣈͷૠೖ: func insertText(String) • Χʔιϧલͷจࣈͷ࡟আ: func deleteBackward() • ΧʔιϧͷҠಈ: func adjustTextPosition(byCharacterOffset: Int) • Keyboard Extension͕ड͚औΕΔ௨஌͸ҎԼͷ2ͭͷΈ • Ϣʔβ͕ʮԿ͔͢Δʯલ: func textWillChange(UITextInput?) • Ϣʔβ͕ʮԿ͔ͨ͠ʯޙ: func textDidChange(UITextInput?) ʢ˞ʣਖ਼֬ʹ͸΋͏গ͋͠Γ·͕͢ɺೖྗ؅ཧʹ࢖͑Δ΋ͷ͸͜Ε͚ͩͰ͢

Slide 40

Slide 40 text

ೖྗঢ়ଶ؅ཧɿϢʔβʹΑΔΧʔιϧҠಈͷݕग़ྫ 1. Ϣʔβ͕ʮԿ͔͢Δʯ௨஌Λड͚औΔ 2. ͜ͷλΠϛϯάͰʮΧʔιϧͷલޙʯͷςΩετΛอଘ(before) 3. Ϣʔβ͕ʮԿ͔ͨ͠ʯ௨஌Λड͚औΔ 4. ͜ͷλΠϛϯάͰʮΧʔιϧͷલޙʯͷςΩετΛอଘ(after) 5. beforeͷࠨӈΛ࿈݁ͨ͠΋ͷͱɺafterͷࠨӈΛ࿈݁ͨ͠΋ͷ͕ಉ͔֬͡ೝ →ಉ͡ͳΒɺςΩετΛมԽͤ͞Δૢ࡞Ͱ͸ͳ͘ɺΧʔιϧҠಈͱ෼͔Δ →beforeͱafterͷࠨͷจࣈ਺Λൺֱ͠ɺ͕ࠩҠಈͨ͠จࣈ਺ͱ෼͔Δ ˞࣮ࡍʹ͸ʮϖʔετʯʮΧοτʯͳͲෳ਺ͷૢ࡞ͷՄೳੑΛಉ࣌ʹௐ΂Δ

Slide 41

Slide 41 text

APIͷ೉͍͠ಈ࡞① • υΩϡϝϯτʹॻ͔Ε͍ͯͳ͍ڍಈ͕ଟ͍ • ΧʔιϧͷҠಈ: func adjustTextPosition(byCharacterOffset: Int) • υΩϡϝϯτʹΑΔͱҾ਺͸Ҡಈ͢Δจࣈ਺ • ࣮ࡍ͸จࣈ਺Ͱ͸ͳ͘UTF-16ίʔυϙΠϯτ਺ • ᷖᮣʹ࣮૷͢ΔͱֆจࣈͷؒʹΧʔιϧ͕ೖͬͨΓ͢Δ • Ҡಈ͢ΔલʹΧʔιϧલޙΛ֬ೝ͠ɺίʔυϙΠϯτΛ਺͑Δඞཁ͕͋Δ

Slide 42

Slide 42 text

APIͷ೉͍͠ಈ࡞② • ೖྗதͷจࣈྻʹ৭͚ͭΔ΍ͭ: func setMarkedText(String?, selectedRange: NSRange) • ৭͸͔֬ʹ͕ͭ͘ɺϢʔβૢ࡞͕Ұ੾τϥοΫग़དྷͳ͘ͳΔ • બ୒͍ͯ͠Δจࣈྻ: var selectedText: String? • υΩϡϝϯτʹΑΔͱબ୒͍ͯ͠Δจࣈྻ • ࣮ࡍ͸ʮબ୒͍ͯ͠Δจࣈྻɻͨͩ͠3ߦҎ্ͷจͷ৔߹͸࠷ॳͱ࠷ޙͷ 1ߦΛ͚ͬͭͨ͘΍ͭʯͱ͍͏ڍಈ • ࢓༷ʢςΩετϑΟʔϧυଆͷ࣮૷ʹΑΔʣ

Slide 43

Slide 43 text

ϝϞϦ੍ݶ • ΩʔϘʔυΞϓϦʹڐ͞ΕͨϝϞϦ͸60MBલޙʢOSɾσόΠεґଘʣ • ্ݶ෇ۙͰ͸ಈ࡞͕ۃ୺ʹ஗͘ͳΔͷͰɺ࣮࣭తʹ͔ͦ͜Β10~20MBఔ౓ݮΔ • ϝϞϦΛফඅ͢ΔཁҼ • ࣙॻσʔλ • ணͤସ͑ͷը૾ • ֆจࣈϑΥϯτͷΩϟογϡ • Ұ౓දࣔ͞Εͨֆจࣈ͸ϝϞϦʹϑΥϯτͷΩϟογϡΛ࢒͢ʢ࡟আෆೳʣ • ֆจࣈશͯͰ10MBҎ্͍͔࣋ͬͯΕΔ→ֆจࣈΩʔϘʔυͰམͪΔʂ

Slide 44

Slide 44 text

UIͷָ͍͠ͱ͜Ζ • ޻෉ͷ༨஍͕ଟ͍ • ৭ʑͳ഑ྻɺศརͳΩʔɺ৽͍͠UIͳͲ • δΣενϟͳͲ΋޻෉Ͱ͖Δ • ΩʔϘʔυͷUIͷՄೳੑΛ୳ΕΔ • ΩʔϘʔυ͸ಛҟͳΞϓϦέʔγϣϯ • ΩʔϘʔυ্Ͱʓʓग़དྷͨΒศརͰ͸ʂΛ ࣮ݱͰ͖Δ

Slide 45

Slide 45 text

·ͱΊ

Slide 46

Slide 46 text

🔥೔ຊޠೖྗ͸Ͱ͖Δʂ 🔥ΩʔϘʔυΞϓϦ΋Ͱ͖Δʂ 🔥೔ຊޠೖྗΞϓϦΛ࡞Ζ͏ʂ ✅ ม׵Τϯδϯɿ͋Δ ✅ ࣮૷αϯϓϧɿ͋Δ ✅ ΦϦδφϧͷ೔ຊޠೖྗΞϓϦɺม׵Τϯδϯɺ഑ྻɺUIɺ࡞Γ·͠ΐ͏ʂ ೔ຊޠೖྗΞϓϦΛ࡞Ζ͏ʂ Your Own Keyboard🔥🔥

Slide 47

Slide 47 text

ϑΟʔυόοΫ͓଴ͪͯ͠·͢

Slide 48

Slide 48 text

͓͢͢Ίͷࢿྉ • Creating a custom keyboard | Apple Developer Documentation, https://developer.apple.com/ documentation/uikit/keyboards_and_input/creating_a_custom_keyboard/ • ޻౻୓, খদ߂޾, ՖԬढ़ߦ, ޲Ҫ३, & ాാ༔հ. (2011). ౷ܭత͔ͳ׽ࣈม׵γεςϜ Mozc. ݴ ޠॲཧֶձୈ 17 ճ೥࣍େձൃද࿦จू, 948-951., https://anlp.jp/proceedings/annual_meeting/2011/pdf_dir/C4-3.pdf • iOSΧελϜΩʔϘʔυͷ࡞Γํ - Qiita, https://qiita.com/Kyome/items/4257de4e33d3647085e6 • ಙӬ୓೭. (2012).೔ຊޠೖྗΛࢧ͑Δٕज़ʕมΘΓଓ͚Δίϯϐϡʔλͱݴ༿ͷੈք, ٕ ज़ධ࿦ࣾ, https://gihyo.jp/book/2012/978-4-7741-4993-6 • KeyboardKit/KeyboardKit - GitHub, https://github.com/KeyboardKit/KeyboardKit