WaniKani / WanaKana

Javascript library for detecting and transforming between Hiragana, Katakana, and Romaji
http://wanakana.com
MIT License
765 stars 76 forks source link

Convert kanji characters to Romaji #81

Closed sharathvignesh closed 6 years ago

sharathvignesh commented 6 years ago

I was using toRomaji API to convert characters to Romaji. While Hiragana and katakana were successfully converted, I found that the kanji characters did not get converted to Romaji. Is there any way to get around this ?

DJTB commented 6 years ago

Kanji only has a reading depending on its context, or rather, which word that kanji is being used in. Wanakana doesn't analyse the semantic content (the meaning) of the input you provide, it only transliterates. It's a complex job to determine which romaji a kanji character should translate to - it's a one-to-many relationship (人 = ひと, にん, じん, -り, -と + jukujikun readings like 大人 = おとな), whereas kana & romaji is one-to-one (ふ = フ = fu).

You can try Kuroshiro which uses Wanakana along with Kuromoji. However, you won't achieve 100% accuracy. For example, 一人 will commonly be presented as いちにん even in a situation where it most likely represents ひとり.

sharathvignesh commented 6 years ago

Thank you @DJTB. Your'e right, it is a complex job to determine which romaji a kanji character should translate to as they have one-to-many relationship.

Thank you for your quick response, I'll try Kuroshiro. 😄

vietqhoang commented 6 years ago

I believe Ve has a JS library which may do kanji → kana. Something to look into. It is a project by Kim of jisho.org.

DJTB commented 6 years ago

@sharathvignesh No problem, best of luck!

Here's a fun one with 5 different readings of 日 to think about: "3月1日は日曜日で祝日、晴れの日でした"

sharathvignesh commented 6 years ago

I found Mecab which was good too. It converts them to Katakana, from which I was able to convert it to romaji using WanaKana's toRomaji.

retorquere commented 6 years ago

The JS version of Ve only connects by http to the ruby version if I'm reading it correctly. It's not usable without that ruby server running I think. mecab executes an executable, so also not usable in a pure-js environment.