SlideShare a Scribd company logo
1 of 36
Download to read offline
Intelligent Pinyin IME
                 Peng Wu
Content

Pinyin IM Background
OSS Pinyin IM Survey
NLP-based Pinyin IM vs non-NLP
sunpinyin vs novel-pinyin
libpinyin - joint efforts
libpinyin - rational
libpinyin roadmap
libpinyin goals
1. Pinyin IM Background
Pinyin IM Background
1. On Windows:
a. most Pinyin IME use sophisticated
techniques (such as NLP...) to improve the
correction rate of pinyin to characters
conversion, without user manually choose
every Chinese word.
b. but ABC Pinyin IM (likes ibus-table) is still
there, some users refused to use new input
approach.
2. On Linux:
a. We are improving, but there are still a long
way to go.
2. OSS Pinyin IM Survey
OSS Pinyin IM Survey

1. Maximum Forward Match:
a. Fcitx
b. ibus-pinyin
2. Uni-gram(or word frequencies based.):
a. scim-pinyin
3. N-gram:
a. sunpinyin
b. novel-pinyin
Maximum Forward Match



Match steps:
1. match the first longest word and forward the
cursor,
2. repeat above steps until all pinyin has been
converted.
uni-gram



1. Statistical-based.
2. Match steps:
1. Try to find the sentence with the most frequent
words.
Concrete Example


Example: zhong'guo'ren
P(中国人|zhong'guo'ren)
= P(中国人)
= P(中国)*P(人)
= 0.001 * 0.001
= 1e-6
Concrete Example(Cont.)


P(种果人|zhong'guo'ren)
= P(种果人)
= P(种果)*P(人)
= 0.0001 * 0.001
= 1e-7
< 1e-6 = P(中国人|zhong'guo'ren)
So we will choose 中国人 as a result.
n-gram



1. Use more sophisticated Statistical Math Model.
2. Match steps:
Find the most possible sentence by using
Statistical Language Model.
(n-gram will be explained later.)
3. NLP-based Pinyin IM
     vs non-NLP
A hypothesis pinyin IM

1. Record all Chinese pinyin/sentence pairs in a
2TB database.
Pros:
1. Nearly 100% correction rates.
Cons:
1. No such huge disk storage to store all pinyin/
sentence pairs.
2. No such powerful CPU can do a pinyin-
sentence conversion in 1 second.
NLP-based Pinyin IM
            vs non-NLP

1. non-NLP based:
Logic is simple, but have problems on
performance and correction rate.
2. NLP based:
Use mathematic models, and computing
intensive, yields more correction rates; or yields
similar correction rates with less computation
time and less disk space.
4. sunpinyin vs
 novel-pinyin
sunpinyin overview


* Built on a back-off n-gram language model (3-gram)
* Supports multiple pinyin schemes (Quanpin & Double Pinyin)
* Supports fuzzy-segmentation, fuzzy-syllables, and auto-
correcting.
* Supports 2-gram history cache, or user's customized model
* Ported to various OS/platforms: iBus, XIM, MacOS
* dual-licensed with CDDL+LGPLv2.1
* Applying the acceptance of Debian, available on Ubuntu,
Fedora and Mandriva ...
sunpinyin intro


1. n-gram based algorithms.
2. Mathematic Model describes:
Try to find the maximum possibility sentence
which can pronounces the given sentence.
3. In recent 3 years, sun-pinyin has been re-
factored to easier be understood.
sunpinyin Math Model

To calculate the probability of sentence S=(W1,W2,W3...
Wn)

P(S) = P(W1).P(W2|W1).P(W3|W1,W2).P(W4|W1,W2,W3)...P(Wn|W1,W2,...Wn-1)




In reality, due to the data sparseness, it's impossible to calculate the
probability in this way. A particle method is, to assume the P(Wi|W1,
W2,...Wi-1) only depends on the previous N words, i.e., Wi-N+1,Wi-N+2,...
Wi-1.

Particularly, we have unigram (N=0,context-free grammar), bigram (N=1),
trigram (N=2), and fourgram (N=3). The most commonly used is bigram,
trigram.
Concrete Example


Example: zhong'guo'ren
P(中国人|zhong'guo'ren)
= P(中国人)
= P(中国)*P(人|中国)
= 0.01 * 0.1
= 0.001
Concrete Example(Cont.)


P(种果人|zhong'guo'ren)
= P(种果人)
= P(种果)*P(人|种果)
= 0.01 * 0.01
= 0.0001
< 0.001 = P(中国人|zhong'guo'ren)
So we will choose 中国人 as a result.
novel-pinyin overview

* Based on an interpolation smoothing of Hidden
Markov Model. (bi-gram)
* Complete support for ShuangPin schemes,
fuzzy pinyin and incomplete pinyin, inherited from
scim-pinyin.
* Improved user input self-learning.
* Appears on some distro, SUSE, Mandriva, aur
etc.
novel-pinyin intro


1. HMM-based (Hidden Markov Model)
algorithms.
2. Mathematic Model describes:
Try to find the maximum possibility sentence
which really pronounces the given sentence.
3. Clear interface design from the beginning,
although algorithms are also complicated as
sunpinyin.
novel-pinyin Math Model



    H stands for Hanzi sequences, P stands for pinyin
                        sequences.
P(H|P) stands for the possibility of the corresponding Hanzi
                   when Pinyin is given.
Math Model (Cont.)
Concrete Example



Example: zhong'guo'ren
P(中国人|zhong'guo'ren)
= P(中国人) *P(zhong'guo'ren|中国人)
= P(中国)*P(人|中国)*P(zhong'guo|中国)*P(ren|人)
= 0.01 * 0.1 * 0.7 * 0.5
= 3.5*10^-4
Concrete Example(Cont.)


P(种果人|zhong'guo'ren)
= P(种果人)*P(zhong'guo'ren|种果人)
= P(种果)*P(人|种果)*P(zhong'guo|种果)*P(ren|人)
= 0.01 * 0.01 * 0.8 * 0.5
= 4.0*10^-5
< 3.5*10^-4 = P(中国人|zhong'guo'ren)
So we will choose 中国人 as a result.
5. libpinyin - joint efforts
libpinyin - joint efforts

1. sunpinyin and novel-pinyin has been competing for 2-3
years.
2. when one input method finished some features, users will
request the other one to implement such features. Combines
the core part can save efforts to re-invent the wheels.
3. in the past two projects both have very limited developer
resources, merging the core part will greatly alleviate this
problem.
6. libpinyin - rational
libpinyin - rational


1. Unique library to process pinyin relative tasks for Chinese,
just likes libchewing, libanthy.
2. NLP-based approach which provides higher corrections
with reasonable speed and space cost.
3. Save efforts to avoid re-developing similar functionality
when need to deal with pinyin or other Chinese tasks, just
use libpinyin directly.
7. libpinyin roadmap
libpinyin roadmap

1. Compare features between ibus-pinyin, novel-pinyin
and sunpinyin, try to figure out the super set of features.
2. Discuss various possible implementations of each
component.
3. Pick up best component implementations from ibus-
pinyin, novel-pinyin and sunpinyin, different
implementations can co-exist.
4. Source code is compiling time configurable, by
specifying the needed flags when compiling, this library
can precisely simulates the behaviors of ibus-pinyin,
novel-pinyin or sunpinyin.
5. Merge source codes, and coding more...
8. libpinyin goals
libpinyin goals

1. Code must be easily maintainable.
2. Consistent interface between components, each component
can evolves independently.
3. Project code can make progress, without re-writing the entire
code base for brand new idea.
4. Ability to include new NLP models, and work seamless with
related components.
5. Consistent coding styles, and the most important thing is to
ease code reading.
6. For hard algorithms, better to write in a separate module,
instead to keep two similar algorithms together(eg, back-off and
interpolation), to ease code reading. Everything which makes
code ease to understand is welcome. :)
Q&A
Thanks

More Related Content

Similar to libpinyin

Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...Yusuke Oda
 
Deep Learning for Machine Translation - A dramatic turn of paradigm
Deep Learning for Machine Translation - A dramatic turn of paradigmDeep Learning for Machine Translation - A dramatic turn of paradigm
Deep Learning for Machine Translation - A dramatic turn of paradigmMeetupDataScienceRoma
 
Intellectual technologies
Intellectual technologiesIntellectual technologies
Intellectual technologiesPolad Saruxanov
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham Yadav
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103Sure Interview
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classificationNarayan Kandel
 
Deep Learning for Natural Language Processing
Deep Learning for Natural Language ProcessingDeep Learning for Natural Language Processing
Deep Learning for Natural Language ProcessingParrotAI
 
2021 04-04-google nmt
2021 04-04-google nmt2021 04-04-google nmt
2021 04-04-google nmtJAEMINJEONG5
 
Unlocking the Power of Integer Programming
Unlocking the Power of Integer ProgrammingUnlocking the Power of Integer Programming
Unlocking the Power of Integer ProgrammingFlorian Wilhelm
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardAnimesh Chaturvedi
 
SPIRE2015-Improved Practical Compact Dynamic Tries
SPIRE2015-Improved Practical Compact Dynamic TriesSPIRE2015-Improved Practical Compact Dynamic Tries
SPIRE2015-Improved Practical Compact Dynamic TriesAndreas Poyias
 
Python programming for Oceanography
Python programming for OceanographyPython programming for Oceanography
Python programming for OceanographyHafez Ahmad
 
NLP using transformers
NLP using transformers NLP using transformers
NLP using transformers Arvind Devaraj
 
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansourPython cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansourOsama Ghandour Geris
 
Moore_slides.ppt
Moore_slides.pptMoore_slides.ppt
Moore_slides.pptbutest
 
Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...
Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...
Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...Codemotion
 
A Simple Explanation of XLNet
A Simple Explanation of XLNetA Simple Explanation of XLNet
A Simple Explanation of XLNetDomyoung Lee
 

Similar to libpinyin (20)

Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
Learning to Generate Pseudo-code from Source Code using Statistical Machine T...
 
Deep Learning for Machine Translation - A dramatic turn of paradigm
Deep Learning for Machine Translation - A dramatic turn of paradigmDeep Learning for Machine Translation - A dramatic turn of paradigm
Deep Learning for Machine Translation - A dramatic turn of paradigm
 
AI applications in education, Pascal Zoleko, Flexudy
AI applications in education, Pascal Zoleko, FlexudyAI applications in education, Pascal Zoleko, Flexudy
AI applications in education, Pascal Zoleko, Flexudy
 
Intellectual technologies
Intellectual technologiesIntellectual technologies
Intellectual technologies
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
Chapter08.pptx
Chapter08.pptxChapter08.pptx
Chapter08.pptx
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classification
 
Deep Learning for Natural Language Processing
Deep Learning for Natural Language ProcessingDeep Learning for Natural Language Processing
Deep Learning for Natural Language Processing
 
2021 04-04-google nmt
2021 04-04-google nmt2021 04-04-google nmt
2021 04-04-google nmt
 
Unlocking the Power of Integer Programming
Unlocking the Power of Integer ProgrammingUnlocking the Power of Integer Programming
Unlocking the Power of Integer Programming
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
SPIRE2015-Improved Practical Compact Dynamic Tries
SPIRE2015-Improved Practical Compact Dynamic TriesSPIRE2015-Improved Practical Compact Dynamic Tries
SPIRE2015-Improved Practical Compact Dynamic Tries
 
Python programming for Oceanography
Python programming for OceanographyPython programming for Oceanography
Python programming for Oceanography
 
NLP using transformers
NLP using transformers NLP using transformers
NLP using transformers
 
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansourPython cs.1.12 week 10  2020 2021 covid 19 for g10 by eng.osama mansour
Python cs.1.12 week 10 2020 2021 covid 19 for g10 by eng.osama mansour
 
Unit -1 CAP.pptx
Unit -1 CAP.pptxUnit -1 CAP.pptx
Unit -1 CAP.pptx
 
Moore_slides.ppt
Moore_slides.pptMoore_slides.ppt
Moore_slides.ppt
 
Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...
Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...
Deep Learning for Machine Translation: a paradigm shift - Alberto Massidda - ...
 
A Simple Explanation of XLNet
A Simple Explanation of XLNetA Simple Explanation of XLNet
A Simple Explanation of XLNet
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

libpinyin

  • 2. Content Pinyin IM Background OSS Pinyin IM Survey NLP-based Pinyin IM vs non-NLP sunpinyin vs novel-pinyin libpinyin - joint efforts libpinyin - rational libpinyin roadmap libpinyin goals
  • 3. 1. Pinyin IM Background
  • 4. Pinyin IM Background 1. On Windows: a. most Pinyin IME use sophisticated techniques (such as NLP...) to improve the correction rate of pinyin to characters conversion, without user manually choose every Chinese word. b. but ABC Pinyin IM (likes ibus-table) is still there, some users refused to use new input approach. 2. On Linux: a. We are improving, but there are still a long way to go.
  • 5. 2. OSS Pinyin IM Survey
  • 6. OSS Pinyin IM Survey 1. Maximum Forward Match: a. Fcitx b. ibus-pinyin 2. Uni-gram(or word frequencies based.): a. scim-pinyin 3. N-gram: a. sunpinyin b. novel-pinyin
  • 7. Maximum Forward Match Match steps: 1. match the first longest word and forward the cursor, 2. repeat above steps until all pinyin has been converted.
  • 8. uni-gram 1. Statistical-based. 2. Match steps: 1. Try to find the sentence with the most frequent words.
  • 9. Concrete Example Example: zhong'guo'ren P(中国人|zhong'guo'ren) = P(中国人) = P(中国)*P(人) = 0.001 * 0.001 = 1e-6
  • 10. Concrete Example(Cont.) P(种果人|zhong'guo'ren) = P(种果人) = P(种果)*P(人) = 0.0001 * 0.001 = 1e-7 < 1e-6 = P(中国人|zhong'guo'ren) So we will choose 中国人 as a result.
  • 11. n-gram 1. Use more sophisticated Statistical Math Model. 2. Match steps: Find the most possible sentence by using Statistical Language Model. (n-gram will be explained later.)
  • 12. 3. NLP-based Pinyin IM vs non-NLP
  • 13. A hypothesis pinyin IM 1. Record all Chinese pinyin/sentence pairs in a 2TB database. Pros: 1. Nearly 100% correction rates. Cons: 1. No such huge disk storage to store all pinyin/ sentence pairs. 2. No such powerful CPU can do a pinyin- sentence conversion in 1 second.
  • 14. NLP-based Pinyin IM vs non-NLP 1. non-NLP based: Logic is simple, but have problems on performance and correction rate. 2. NLP based: Use mathematic models, and computing intensive, yields more correction rates; or yields similar correction rates with less computation time and less disk space.
  • 15. 4. sunpinyin vs novel-pinyin
  • 16. sunpinyin overview * Built on a back-off n-gram language model (3-gram) * Supports multiple pinyin schemes (Quanpin & Double Pinyin) * Supports fuzzy-segmentation, fuzzy-syllables, and auto- correcting. * Supports 2-gram history cache, or user's customized model * Ported to various OS/platforms: iBus, XIM, MacOS * dual-licensed with CDDL+LGPLv2.1 * Applying the acceptance of Debian, available on Ubuntu, Fedora and Mandriva ...
  • 17. sunpinyin intro 1. n-gram based algorithms. 2. Mathematic Model describes: Try to find the maximum possibility sentence which can pronounces the given sentence. 3. In recent 3 years, sun-pinyin has been re- factored to easier be understood.
  • 18. sunpinyin Math Model To calculate the probability of sentence S=(W1,W2,W3... Wn) P(S) = P(W1).P(W2|W1).P(W3|W1,W2).P(W4|W1,W2,W3)...P(Wn|W1,W2,...Wn-1) In reality, due to the data sparseness, it's impossible to calculate the probability in this way. A particle method is, to assume the P(Wi|W1, W2,...Wi-1) only depends on the previous N words, i.e., Wi-N+1,Wi-N+2,... Wi-1. Particularly, we have unigram (N=0,context-free grammar), bigram (N=1), trigram (N=2), and fourgram (N=3). The most commonly used is bigram, trigram.
  • 19. Concrete Example Example: zhong'guo'ren P(中国人|zhong'guo'ren) = P(中国人) = P(中国)*P(人|中国) = 0.01 * 0.1 = 0.001
  • 20. Concrete Example(Cont.) P(种果人|zhong'guo'ren) = P(种果人) = P(种果)*P(人|种果) = 0.01 * 0.01 = 0.0001 < 0.001 = P(中国人|zhong'guo'ren) So we will choose 中国人 as a result.
  • 21. novel-pinyin overview * Based on an interpolation smoothing of Hidden Markov Model. (bi-gram) * Complete support for ShuangPin schemes, fuzzy pinyin and incomplete pinyin, inherited from scim-pinyin. * Improved user input self-learning. * Appears on some distro, SUSE, Mandriva, aur etc.
  • 22. novel-pinyin intro 1. HMM-based (Hidden Markov Model) algorithms. 2. Mathematic Model describes: Try to find the maximum possibility sentence which really pronounces the given sentence. 3. Clear interface design from the beginning, although algorithms are also complicated as sunpinyin.
  • 23. novel-pinyin Math Model H stands for Hanzi sequences, P stands for pinyin sequences. P(H|P) stands for the possibility of the corresponding Hanzi when Pinyin is given.
  • 25. Concrete Example Example: zhong'guo'ren P(中国人|zhong'guo'ren) = P(中国人) *P(zhong'guo'ren|中国人) = P(中国)*P(人|中国)*P(zhong'guo|中国)*P(ren|人) = 0.01 * 0.1 * 0.7 * 0.5 = 3.5*10^-4
  • 26. Concrete Example(Cont.) P(种果人|zhong'guo'ren) = P(种果人)*P(zhong'guo'ren|种果人) = P(种果)*P(人|种果)*P(zhong'guo|种果)*P(ren|人) = 0.01 * 0.01 * 0.8 * 0.5 = 4.0*10^-5 < 3.5*10^-4 = P(中国人|zhong'guo'ren) So we will choose 中国人 as a result.
  • 27. 5. libpinyin - joint efforts
  • 28. libpinyin - joint efforts 1. sunpinyin and novel-pinyin has been competing for 2-3 years. 2. when one input method finished some features, users will request the other one to implement such features. Combines the core part can save efforts to re-invent the wheels. 3. in the past two projects both have very limited developer resources, merging the core part will greatly alleviate this problem.
  • 29. 6. libpinyin - rational
  • 30. libpinyin - rational 1. Unique library to process pinyin relative tasks for Chinese, just likes libchewing, libanthy. 2. NLP-based approach which provides higher corrections with reasonable speed and space cost. 3. Save efforts to avoid re-developing similar functionality when need to deal with pinyin or other Chinese tasks, just use libpinyin directly.
  • 32. libpinyin roadmap 1. Compare features between ibus-pinyin, novel-pinyin and sunpinyin, try to figure out the super set of features. 2. Discuss various possible implementations of each component. 3. Pick up best component implementations from ibus- pinyin, novel-pinyin and sunpinyin, different implementations can co-exist. 4. Source code is compiling time configurable, by specifying the needed flags when compiling, this library can precisely simulates the behaviors of ibus-pinyin, novel-pinyin or sunpinyin. 5. Merge source codes, and coding more...
  • 34. libpinyin goals 1. Code must be easily maintainable. 2. Consistent interface between components, each component can evolves independently. 3. Project code can make progress, without re-writing the entire code base for brand new idea. 4. Ability to include new NLP models, and work seamless with related components. 5. Consistent coding styles, and the most important thing is to ease code reading. 6. For hard algorithms, better to write in a separate module, instead to keep two similar algorithms together(eg, back-off and interpolation), to ease code reading. Everything which makes code ease to understand is welcome. :)
  • 35. Q&A