• Stars
    star
    124
  • Rank 279,783 (Top 6 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Hepburn

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

Based partly on Takaaki Komura's kana2hepburn.

Install

npm install hepburn

Usage

var hepburn = require("hepburn");

fromKana(string)

var romaji1 = hepburn.fromKana("γ²γ‚‰γŒγͺ");
var romaji2 = hepburn.fromKana("γ‚«γ‚Ώγ‚«γƒŠ");

Converts a string containing Kana, either Hiragana or Katakana, to Romaji.

In this example romaji1 will have the value HIRAGANA, romaji2 will have the value KATAKANA.

toHiragana(string)

var hiragana = hepburn.toHiragana("HIRAGANA");

Converts a string containing Romaji to Hiragana.

In this example hiragana will have the value γ²γ‚‰γŒγͺ.

toKatakana(string)

var katakana = hepburn.toKatakana("KATAKANA");
var tokyo = hepburn.toKatakana("TŌKYŌ");

Converts a string containing Romaji to Katakana.

In this example katakana will have the value γ‚«γ‚Ώγ‚«γƒŠ and tokyo will have the value γƒˆγƒΌγ‚­γƒ§γƒΌ.

cleanRomaji(string)

var cleaned = hepburn.cleanRomaji("SYUNNEI");
// cleaned === "SHUN'EI"

Cleans up a romaji string, changing old romaji forms into the more-modern Hepburn form (for further processing). Generally matches the style used by Wapro romaji. A larger guide to modern romaji conventions was 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 usages Nihon-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".

splitKana(string)

var hiragana = hepburn.splitKana("γ²γ‚‰γŒγͺ");
var tokyo = hepburn.splitKana("γƒˆγƒΌγ‚­γƒ§γƒΌ");

Splits a string containing Katakana or Hiragana into a syllables array.

In this example hiragana will have the value ["ひ", "ら", "が", "γͺ"] and tokyo will have the value ["γƒˆγƒΌ", "キョー"].

splitRomaji(string)

var tokyo = hepburn.splitRomaji("TŌKYŌ");
var pakkingu = hepburn.splitRomaji("PAKKINGU");

Splits a string containing Romaji into a syllables array.

In this example tokyo will have the value ["TŌ", "KYŌ"] and pakkingu will have the value ["PAK", "KI", "N", "GU"].

containsHiragana(string)

Returns true if string contains Hiragana.

containsKatakana(string)

Returns true if string contains Katakana.

containsKana(string)

Returns true if string contains any Kana.

containsKanji(string)

Returns true if string contains any Kanji.

Testing Build 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 at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed 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 and limitations under the License.

More Repositories

1

sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
JavaScript
27,645
star
2

limax

Node.js module to generate URL slugs. Another one? This one cares about i18n and transliterates non-Latin scripts to conform to the RFC3986 standard. Mostly API-compatible with similar modules.
JavaScript
572
star
3

farmhash

Node.js implementation of FarmHash, Google's family of high performance hash functions
JavaScript
378
star
4

highwayhash

Node.js implementation of HighwayHash, Google's fast and strong hash function
JavaScript
210
star
5

sharp-libvips

Packaging scripts to prebuild libvips and its dependencies - you're probably looking for https://github.com/lovell/sharp
Shell
161
star
6

avif-cli

Command line utility to convert images to AVIF
JavaScript
139
star
7

64

High performance Base64 encoding and decoding for Node.js using SIMD (AVX2, AVX, SSE4.2, SSE4.1, SSSE3) acceleration
JavaScript
108
star
8

attention

No longer maintained - Node.js module to detect the dominant palette and salient region of an image
C++
56
star
9

detect-libc

Node.js module to detect details of the C standard library (libc) implementation provided by a given Linux system
JavaScript
55
star
10

icc

JavaScript module to parse International Color Consortium (ICC) profiles
JavaScript
54
star
11

shorter

Node.js module to very quickly (de)compress short strings. Uses the SIMD-powered entropy encoding features of shoco.
JavaScript
32
star
12

nginx-cache

Node.js module to find files in an Nginx cache based on partial URL keys
JavaScript
25
star
13

media-type

JavaScript module to parse and validate RFC6838 media types, anything from 'text/plain' to 'application/vnd.company.app.entity-v2+xml;charset=utf8'
JavaScript
15
star
14

libimagequant

libimagequant v2.4.1 fork (BSD-2-Clause) with support for building and cross-compiling via meson
C
11
star
15

uk-postcode

Node.js module for parsing and validating UK postcodes
JavaScript
11
star
16

cc

Code style linter for C++ source files used in Node.js native addons
JavaScript
10
star
17

cgif-packaging

Packaging scripts for cgif
Shell
8
star
18

package-libvips-darwin

Superseded by https://github.com/lovell/sharp-libvips
Ruby
5
star
19

deephouse.uk

Nunjucks
5
star
20

petra

Embed a caching, reverse HTTP proxy into an existing distributed ES6 web application
JavaScript
5
star
21

libvips-cpp-dll

DEPRECATED
JavaScript
2
star
22

aarch64-linux-musl-crosstools

Cross-compiler toolchain to produce linuxmusl-arm64v8 binaries on linuxmusl-x64
C++
2
star
23

rampart

Reverse HTTP proxy backed by distributed memory cache. Designed to protect APIs from intense GET request traffic spikes.
JavaScript
1
star
24

wi-scrapbook

Stoke Ferry WI Scrapbook 1965. Images are licensed under a Creative Commons BY-NC-SA 4.0 International License.
JavaScript
1
star
25

broad-norfolk

English to Broad Norfolk Translator
JavaScript
1
star
26

lovell.info

JavaScript
1
star
27

sharp-osx-ci

DEPRECATED
1
star
28

counted

Capture, store and track download_count values for assets distributed via Github Releases
JavaScript
1
star