Skip to main content

Transliterate/transcribe from other languages into Thai

Project description

Wunsen

Wunsen transliterates/transcribes from other languages into Thai.

วุ้นเส้นสามารถทับศัพท์จากภาษาต่างๆ มาเป็นภาษาไทย

Currently support:

  • Japanese (from Hepburn romanization)
  • Korean (from Revised Romanization)
  • Mandarin (from Hanyu Pinyin)
  • Vietnamese (Latin script)

Demo here.

Installation

Requirement:

Python >= 3.7

khanaa

pip install wunsen

Usage

from wunsen import ThapSap

# Japanese
thap_ja = ThapSap('ja')
thap_ja.thap('ohayō')
# => 'โอฮาโย'

# without macron
thap_ja_no_macron = ThapSap('ja', input='Hepburn-no diacritic')
thap_ja_no_macron.thap('ohayou')
# => 'โอฮาโย'

# another transliteration system for Japanese
thap_ja = ThapSap('ja', system='RI35')
thap_ja.thap('ohayō')
# => 'โอะฮะโย'

# Korean
thap_ko = ThapSap('ko')
thap_ko.thap('annyeonghaseyo')
# => 'อันนย็องฮาเซโย'

# Mandarin (Pinyin with tone diacritics is not supported yet.)
thap_zh = ThapSap('zh', system='RI49')
thap_zh.thap('ni3 hao3')
# => 'หนี ห่าว'

thap_zh = ThapSap('zh', system='THC43')
thap_zh.thap('ni3 hao3')
# => 'หนี เห่า'

# Vietnamese
thap_vi = ThapSap('vi')
thap_vi.thap('xin chào')
# => 'ซีน จ่าว'

Transcription/Transliteration System in Wunsen

There might be some differences between Wunsen result and the intended result from the actual system, so please review the results.

  • Japanese =>
    • หลักเกณฑ์การทับศัพท์ภาษาญี่ปุ่น (สำนักงานราชบัณฑิตยสภา พ.ศ. 2561) 'ORS61'
    • หลักเกณฑ์การทับศัพท์ภาษาญี่ปุ่น (ราชบัณฑิตยสถาน พ.ศ. 2535) 'RI35'
  • Korean => หลักเกณฑ์การทับศัพท์ภาษาเกาหลี (ราชบัณฑิตยสถาน พ.ศ. 2555) 'RI55'
  • Mandarin =>
    • หลักเกณฑ์การทับศัพท์ภาษาจีน (ราชบัณฑิตยสถาน พ.ศ. 2549) 'RI49'
    • เกณฑ์การถ่ายทอดเสียงภาษาจีนแมนดารินด้วยอักขรวิธีไทย (คณะกรรมการสืบค้นประวัติศาสตร์ไทยในเอกสารภาษาจีน พ.ศ. 2543) 'THC43'
  • Vietnamese => หลักเกณฑ์การทับศัพท์ภาษาเวียดนาม (ราชบัณฑิตยสถาน พ.ศ. 2555) 'RI55'

Wunsen is not affiliated with proposers of the above transliteration systems.

วุ้นเส้นไม่มีส่วนเกี่ยวข้องกับผู้กำหนดแนวทางการทับศัพท์แต่อย่างใด

Notes

Syllabification Issues

Wunsen might break syllables in incorrect place. You might have to add apostrophe:

thap_ja.thap("honya | hon'ya")
# => "โฮเนีย | ฮงยะ"

thap_ko.thap("waengwaeng, maeum | waeng'waeng, ma'eum")
# => "แว็นกแว็ง, แมอุม | แว็งแว็ง, มาอึม"

Mandarin Tone Sandhi

For Mandarin, both transliteration systems specify that we should apply third tone sandhi rule to the Thai result. Wunsen will automatically apply it, but you can turn it off.

thap_zh_no_sandhi = ThapSap('zh', option={'sandhi': False})
thap_zh_no_sandhi.thap('ni3 hao3')
# => 'หนี่ เห่า' / ni3 hao3

# if we turn it on
thap_zh_with_sandhi = ThapSap('zh', option={'sandhi': True})
thap_zh_with_sandhi.thap('ni3 hao3')
# => 'หนี เห่า' / ni2 hao3

thap_zh_with_sandhi.thap('ni3hao3')
# => 'หนีเห่า' / ni2hao3

# examples from wikipedia
thap_zh_with_sandhi.thap('bao3guan3 hao3')
# => 'เป๋าก๋วน เห่า' / bao2guan2 hao3

thap_zh_with_sandhi.thap('lao3 bao3guan3')
# => 'เหล่า เป๋าก่วน' / lao3 bao2guan3

Wunsen doesn't apply 不 (bù) and 一 (yī) tone rules as they are difficult to recognize in Pinyin.

Japanese long vowels

Although we should transcribe two short vowels from different origins, that are next to each other, as two short vowels (not one long vowel), Wunsen cannot cover this case reliably.

thap_ja.thap("公子 kōshi | 子牛 koushi | 石井 Ishii | ただいま tadaima")
# => "公子 โคชิ | 子牛 โคอูชิ | 石井 อิชิอิ | ただいま ทาไดมะ"
# kōshi, koushi, Ishii are fine but tadaima is ta-dai-ma in Wunsen instead of ta-da-i-ma

thap_ja_no_macron.thap("公子 koushi | 子牛 koushi | 石井 Ishii | ただいま tadaima")
# => "公子 โคชิ | 子牛 โคชิ | 石井 อิชี | ただいま ทาไดมะ"
# they're transcribed as kou-shi | kou-shi | i-shii | ta-dai-ma so they're incorrect except 公子

Spacing in Thai

If we want to follow the actual transcription/transliteration system, in some cases, space between syllables or words might have to be deleted in Thai result.

For example, หลักเกณฑ์การทับศัพท์ภาษาเวียดนาม (ราชบัณฑิตยสถาน พ.ศ. 2555) (Vietnamese system) specifies that space in Vietnamese place names should be deleted, but in personal name, the space should still be there as in Vietnamese.

Because it depends on the situation, Wunsen will leave spacing as it is.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wunsen-0.0.3.tar.gz (23.0 kB view hashes)

Uploaded Source

Built Distribution

wunsen-0.0.3-py3-none-any.whl (21.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page