• Stars
    star
    163
  • Rank 229,802 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 4 years ago

Reviews

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

Repository Details

Util collection for Japanese text processing. Hiraganize, Katakanize, and Romanize.

japanese.js NPM version Build Status Coverage Status Dependency Status Greenkeeper badge

Util collection for Japanese text processing. Hiraganize, Katakanize, and Romanize.

Install

$ npm install --save japanese

Usage

var japanese = require('japanese');

japanese.hiraganize('ヱヴァンゲリヲン');

For crazy syntax sugar junkies:

var japanese = require('japanese/sugar');

'ヱヴァンゲリヲン'.hiraganize();

Command

Command Line Interface is also available.

$ npm install japanese -g
$ japanese

  Util collection for Japanese text processing. Hiraganize, Katakanize, and Romanize.

  Usage:
    japanese <input> [options]

  Options:
    -h, --hiraganize   hiraganize input string
    -k, --katakanize   katakanize input string
    -r, --romanize     romanize input string

  Example
    japanese ヱヴァンゲリヲン --hiraganize

API

japanese.hiraganize(text)

Convert input katakana into hiragana.

Arguments

  • text The text to hiraganize

Example

japanese.hiraganize('ヱヴァンゲリヲン');     // ゑゔぁんげりをん
japanese.hiraganize('チヨコバナヽ');         // ちよこばなゝ
japanese.hiraganize('ヹルタースオリジナル'); // ゑ゙るたーすおりじなる
japanese.hiraganize('板垣死ス𪜈');           // 板垣死すとも

japanese.katakanize(text)

Convert input hiragana into katakana.

Arguments

  • text The text to katakanize

Example

japanese.katakanize('抹茶あいす');       // 抹茶アイス
japanese.katakanize('ばゞへらあいす');   // バヾヘラアイス
japanese.katakanize('ゐ゙よろん');         // ヸヨロン
japanese.katakanize('本日ゟかき氷解禁'); // 本日ヨリカキ氷解禁

japanese.romanize(text[, config])

Convert input text into romaji.

important: Most definitions of Japanese text romanizations require total recognition of Japanese text, but robots cannot actually think or understand! Some conversions are hopelessly poor. For example, ISO 3602 defines that "こうし" which means "講師" must be romanized as "kôsi", while "こうし" which means "子牛" must be romanized as "kousi" (because 子牛 is mixed word of 子 and 牛), though these are apparently the same in Kana-form. While japanese.js is very... very very thoroughly tested, this module (and any other romanization machines) cannot distinguish between these semantics. So unfortunately, you cannot use this function for official writing or something. Ugh.

Arguments

  • text The text to romanize
  • config The configuration object or string used to romanize. Described below.

Example

japanese.romanize('れんあいかんじょう');       // ren'aikanjō
japanese.romanize('ツァトゥグァ');             // tsatugwa
japanese.romanize('くうぼをきゅう', 'kunrei'); // kûbookyû
japanese.romanize('でんぢゃらす', 'nihon');    // dendyarasu
japanese.romanize('いいづか とおる', {
	'いい': 'ii',
	'おお': 'oh',
});                                            // iizuka tohru

Configs

Config is represented as plain object, where object keys stand for a collection of similar characters, and the value determines how these characters are converted. So the object is not just the same as a conversion table.

Available parameters are following.

Key Available Values
si, shi
ti, chi
tu, tsu
hu, fu
zi, ji
di, zi, ji, dzi, dji
du, zu, dsu, dzu
ああ aa, ah, â, ā, a
いい ii, ih, î, ī, i
うう uu, uh, û, ū, u
ええ ee, eh, ê, ē, e
おお oo, oh, ô, ō, o
あー a-, aa, ah, â, ā, a
えい ei, ee, eh, ê, ē, e
おう ou, oo, oh, ô, ō, o
んあ na, n'a, n-a
んば nba, mba
っち tti, tchi, cchi
i, wi
o, wo

You can also specify these predefined configs by supplying a string. Default is wikipedia.

'wikipedia' 'traditional hepburn' 'modified hepburn' 'kunrei' 'nihon'
shi shi shi si si
chi chi chi ti ti
tsu tsu tsu tu tu
fu fu fu hu hu
ji ji ji zi zi
ji ji ji zi di
zu zu zu zu du
ああ aa aa ā â ā
いい ii ii ii î ī
うう ū ū ū û ū
ええ ee ee ē ê ē
おお ō ō ō ô ō
あー ā ā ā â ā
えい ei ei ei ei ei
おう ō ō ō ô ō
んあ n'a n-a n'a n'a n'a
んば nba mba nba nba nba
っち tchi tchi tchi tti tti
i i i i wi
o wo o o wo

And here are short notes about these romanizations.

Wikipedia style

Source: http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Japan-related_articles#Romanization

The most modern and widely used form of romanization. Wikipedia uses this guideline to name their article title and text. This is mixed version of traditional and modified Hepburn and easily recognizable for everyone.

Traditional and Modified Hepburn

Source: http://en.wikipedia.org/wiki/Hepburn_romanization

Actually this is not a specification. Hepburn romanization is very widely known but nobody other than Hepburn knows the REAL definition of these method.

Kunrei-shiki and Nihon-shiki

Source: http://www.iso.org/iso/catalogue_detail.htm?csnumber=9029

Kunrei-shiki is defined as ISO 9029 and Nihon-shiki as ISO 9209 Strict. These romanizations are today kind of obsolete but still the only standardized romanization in the world.

Roadmap

  • japanese.deromanize()
  • japanese.cyrillize()
  • japanese.decyrillize()
  • japanese.hangulize()
  • japanese.dehangulize()
  • japanese.arabize()
  • japanese.dearabize()
  • japanese.gyarumojize()
  • japanese.isKatakana()
  • japanese.isHiragana()
  • japanese.isKanji()
  • japanese.isJoyoKanji()
  • japanese.isKinsoku() (JIS X 4051 compatibility is preferred)
  • CLI
    • --input <file> and --output <file> option
    • japanese --hiraganize <string> to work

...and any proposal or idea for enhancing japanese.js is welcomed! Tell me, tell me, tell me!

License

MIT © hakatashi

More Repositories

1

RictyDiminished-with-FiraCode

日本一美しいプログラミングフォント Ricty Diminished に、FiraCodeのプログラミング合字をミックス。
Python
119
star
2

smart-cube-timer

Proof-of-concept smart timer for GiiKER
JavaScript
68
star
3

esolang-box

Easy and standardized docker images for 200+ esoteric (and non-esoteric) languages.
Dockerfile
42
star
4

ac-library.cr

Port of ac-library implemented in Crystal Programming Language
Crystal
40
star
5

giiker

JavaScript wrapper for GiiKER smart cube Bluetooth API
JavaScript
36
star
6

iwashi

イワシを生やす
JavaScript
33
star
7

kindlegen

Simple Node.js wrapper for kindlegen program
LiveScript
23
star
8

slack-ikku

一句
LiveScript
22
star
9

UT-notebooks

Collection of my notebooks taken in UT
TeX
22
star
10

pentest

Full-automated dynamic vulnerability scanning tool for Ruby on Rails project
Ruby
20
star
11

atcoder-auto-submitter

Fully-automated AtCoder submitter backed by OpenAI Codex.
Python
20
star
12

kyujitai.js

Utility collections for making Japanese text old-fashioned
JavaScript
19
star
13

YouTyping

UTyping on browser
JavaScript
15
star
14

osekkai

日本語平文を組版に合わせて最適化する、出版史上最もお節介な機能
JavaScript
13
star
15

sugoi-converter

The Ninja Converter
CoffeeScript
13
star
16

esolang-battle

[+.<] Win the esolang master!!!
JavaScript
12
star
17

jquery.howmuchread

Answers your fancy questions such as "How many characters I scrolled?"
JavaScript
12
star
18

human-or-vocaloid-quiz

TypeScript
7
star
19

poems

宮沢賢治がGitを使っていれば、銀河鉄道の夜の初稿も散逸しなかったでしょう
5
star
20

AsianBreak

Line Break for East Asian People
LiveScript
5
star
21

HakataFont

HakataFont Project
HTML
5
star
22

tsg-ai-arena

AI battle system for TSG
JavaScript
5
star
23

tokyo-olym.pics

四角形を動かしたりくっつけたりできるサイトです。四角形を動かしたりくっつけたりしましょう。
Vue
5
star
24

HTML5-niconicoplayer

Video.js plugin to cope with niconico comment
CoffeeScript
5
star
25

chars

“Semmantically-correct” JavaScript module to split string into array of characters.
LiveScript
5
star
26

hkt.sh

Go
4
star
27

slack-imas-birthday

JavaScript
4
star
28

coupling.moe

全てのカップリングを応援します
Vue
4
star
29

aozora-ruby

😛青空文庫形式のルビ(を拡張したもの)を他形式に変換する😛
LiveScript
4
star
30

eeic2017-i1i2i3

2017年度EEIC 電気電子情報実験演習 I実験課題
C
4
star
31

replybot

Reply bot powered by twitter corpus
HTML
4
star
32

IVS.js

This module supplies mutual IVS conversion between Adobe-Japan and Hanyo-denshi(Moji_Joho)
JavaScript
3
star
33

pixivwall

Bring your moe to your desktop! This Windows app automatically downloads and sets wallpapers from today's pixiv ranking.
CoffeeScript
3
star
34

kanji-factory

CoffeeScript
3
star
35

general-category

Look up General_Category of Unicode character with JavaScript
LiveScript
3
star
36

takuboku-project

takuboku-project
Python
3
star
37

heartbeat.hakatashi.com

Keep alive
3
star
38

emoji

Emoji created by hakatashi
Shell
3
star
39

rinna_slackbot

Python
3
star
40

hakatabot

Deal with hakatashi's daily nonsenses.
JavaScript
3
star
41

color-of-anime

JavaScript
3
star
42

eslint-plugin-array-plural

ESLint plugin to force usage of plural noun to name array variables
JavaScript
3
star
43

tsg-live-block

TSG LIVE! 2 当日ライブコーディング用リポジトリ
JavaScript
3
star
44

namori_rakugaki_annotation

なもり先生がTwitterにアップロードしている「最近のらくがき」に対するキャラクター名・作品名のアノテーションデータ
TypeScript
3
star
45

StrangeTails

2
star
46

TakahashiTETRIS

TETRIS produced by Takahashi. That's all for now.
C++
2
star
47

imas-official-comics-feed

アイドルマスターシリーズの公式マンガ (4コマなど) の更新情報を垂れ流すAtomフィード
JavaScript
2
star
48

kammusu-means

「K-means法」と「混合ガウス分布のEMアルゴリズム」をブラウザ上でビジュアライズするやつ
JavaScript
2
star
49

benchmarker-webapp

pixivの社内ISUCONのポータルサイトの簡易実装
JavaScript
2
star
50

jquery.vertical-rl

Japanese vertical typography, with least hack!
JavaScript
2
star
51

hakatashi

2
star
52

word.hakatashi.com

hakatashiが個人的に書き留めている単語帳から一日一語ずつ紹介します
Stylus
2
star
53

procon

Crystal
2
star
54

kammusu-map

kammusu-map
JavaScript
2
star
55

niconico-comment-downloader

CoffeeScript
2
star
56

sandbox

2
star
57

unicue-lang

esolang
JavaScript
2
star
58

KageEngine-test

JavaScript
2
star
59

decathlon

TypeScript
2
star
60

mahjong.hakatashi.com

JavaScript
2
star
61

base16-colors-scheme

Base16 color scheme based on the Colors project (https://clrs.cc/) by @mrmrs
2
star
62

onara

Comprehensive Onara collection for all programmers.
Java
2
star
63

pixiv-novels-downloader-web

Automatically download pixiv novels to 青空文庫-compatible text file with simple web interfaces.
JavaScript
2
star
64

sos.hakatashi.com

Send SOS to hakatashi
HTML
2
star
65

nada.hakatashi.com

Hakatashi's Nada-Print Database Host
JavaScript
1
star
66

api.hakatashi.com

“Without API, life would be a mistake.”
JavaScript
1
star
67

dotfiles

You already know what this repository is.
Shell
1
star
68

technically

Get the exact value of the number
LiveScript
1
star
69

twicpp

Archive from my old development folder
C++
1
star
70

webhook.hakatashi.com

Tiny Router for My Personal Webhooks
JavaScript
1
star
71

tahoiya-generator

Generate random string for tahoiya
Vue
1
star
72

emoji-vision

Public mirror of https://github.com/InfovisHandsOn/A_D4
Jupyter Notebook
1
star
73

shinycolors-assets-downloader

TypeScript
1
star
74

nicopedia-dataset-parser

JavaScript
1
star
75

UTypingAssistance

Archive from my old development folder
C
1
star
76

isucon6-final

JavaScript
1
star
77

slack-yahoo-uranai

今日のYahoo占いのかに座♋の運勢をSlackに投稿するやつ
LiveScript
1
star
78

unicode-karuta

JavaScript
1
star
79

nicovideo-dl

Personal fork of http://sourceforge.jp/projects/nicovideo-dl/
1
star
80

pixiv2kindle-chrome

JavaScript
1
star
81

SunPro-C89-hakatashi

Ruby
1
star
82

SunPro-C91

SunPro会誌 C91発行版
C++
1
star
83

isucon2018-final

チーム「sunpro'); DROP TABLE members;--」
PHP
1
star
84

iwashi-editor

Online editor and player for &#34;iwashi&#34; esoteric language
Vue
1
star
85

TonyuArchives

The very beginning of hakatashi
1
star
86

sclipting-escape

A node.js module to escape String/Number/Buffer into ByteArray literal of Sclipting programming language.
TypeScript
1
star
87

NPCA-Christmas-Golf

クリスマスはゴルフ、はっきりわかんだね
CSS
1
star
88

vigilant-fortnight

TypeScript
1
star
89

mitoh17-prototype

JavaScript
1
star
90

slackbot-anime-thumber

JavaScript
1
star
91

rhythm-medley

TypeScript
1
star
92

is-ikku

1
star
93

eeic2017bot

EEICたん
JavaScript
1
star
94

node-vrm-validator

JavaScript
1
star
95

DragonASIC-web

DEPRECATED: This project has been moved to https://github.com/DragonASIC/DragonASIC
JavaScript
1
star
96

pixiv-slack-emoji-typing

pixivのSlackの絵文字を組み合わせて1番面白い奴が優勝ジェネレーター
JavaScript
1
star
97

sunrise-bot

季節を感じるためのslackbot
JavaScript
1
star
98

novels

人類のことは嫌いになっても、この世界のことは嫌いにならないでください
1
star
99

SunPro-techbookfest2

『SunPro 技術書典2017(仮)』 開発用リポジトリ
OCaml
1
star
100

isucon8-qual

Perl
1
star