- Notifications
You must be signed in to change notification settings - Fork23
Node.js module for converting Japanese Hiragana and Katakana script to, and from, Romaji using Hepburn romanisation
License
lovell/hepburn
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Node.js module for converting Japanese Hiragana and Katakana script to, and from, Romaji usingHepburn romanisation.
Based partly on Takaaki Komura'skana2hepburn.
npm install hepburn
varhepburn=require("hepburn");
varromaji1=hepburn.fromKana("ひらがな");varromaji2=hepburn.fromKana("カタカナ");
Converts a string containing Kana, either Hiragana or Katakana, to Romaji.
In this exampleromaji1
will have the valueHIRAGANA
,romaji2
will have the valueKATAKANA
.
varhiragana=hepburn.toHiragana("HIRAGANA");
Converts a string containing Romaji to Hiragana.
In this examplehiragana
will have the valueひらがな
.
varkatakana=hepburn.toKatakana("KATAKANA");vartokyo=hepburn.toKatakana("TŌKYŌ");
Converts a string containing Romaji to Katakana.
In this examplekatakana
will have the valueカタカナ
andtokyo
will have the valueトーキョー
.
varcleaned=hepburn.cleanRomaji("SYUNNEI");// cleaned === "SHUN'EI"
Cleans up a romaji string, changing old romaji forms into the more-modernHepburn form (for further processing). Generally matches the style used byWapro romaji.A largerguide to modern romaji conventionswas used in building this method.
What this methods fixes:
- Incorrect usage of the letter M. For example "Shumman" should be written as "Shunman".
- Changing usage of NN into N', for example "Shunnei" becomes "Shun'ei".
- Converting the usage of OU and OH (to indicate a long vowel) into OO.
- Correct old usagesNihon-shiki romanization into Hepburn form. A full list of the conversions can be found in the
hepburn.js
file. For example "Eisyosai" becomes "Eishosai" and "Yoshihuji" becomes "Yoshifuji".
varhiragana=hepburn.splitKana("ひらがな");vartokyo=hepburn.splitKana("トーキョー");
Splits a string containing Katakana or Hiragana into a syllables array.
In this examplehiragana
will have the value["ひ", "ら", "が", "な"]
andtokyo
will have the value["トー", "キョー"]
.
vartokyo=hepburn.splitRomaji("TŌKYŌ");varpakkingu=hepburn.splitRomaji("PAKKINGU");
Splits a string containing Romaji into a syllables array.
In this exampletokyo
will have the value["TŌ", "KYŌ"]
andpakkingu
will have the value["PAK", "KI", "N", "GU"]
.
Returnstrue
ifstring
contains Hiragana.
Returnstrue
ifstring
contains Katakana.
Returnstrue
ifstring
contains any Kana.
Returnstrue
ifstring
contains any Kanji.
Run the unit tests with:
npm test
Copyright 2013, 2014, 2015, 2018, 2020 Lovell Fuller and contributors.
Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
About
Node.js module for converting Japanese Hiragana and Katakana script to, and from, Romaji using Hepburn romanisation
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors10
Uh oh!
There was an error while loading.Please reload this page.