Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Node.js module for converting Japanese Hiragana and Katakana script to, and from, Romaji using Hepburn romanisation

License

NotificationsYou must be signed in to change notification settings

lovell/hepburn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Install

npm install hepburn

Usage

varhepburn=require("hepburn");

fromKana(string)

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.

toHiragana(string)

varhiragana=hepburn.toHiragana("HIRAGANA");

Converts a string containing Romaji to Hiragana.

In this examplehiragana will have the valueひらがな.

toKatakana(string)

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トーキョー.

cleanRomaji(string)

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 thehepburn.js file. For example "Eisyosai" becomes "Eishosai" and "Yoshihuji" becomes "Yoshifuji".

splitKana(string)

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["トー", "キョー"].

splitRomaji(string)

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"].

containsHiragana(string)

Returnstrue ifstring contains Hiragana.

containsKatakana(string)

Returnstrue ifstring contains Katakana.

containsKana(string)

Returnstrue ifstring contains any Kana.

containsKanji(string)

Returnstrue ifstring contains any Kanji.

TestingBuild Status

Run the unit tests with:

npm test

Licence

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

Stars

Watchers

Forks

Packages

No packages published

Contributors10


[8]ページ先頭

©2009-2025 Movatter.jp