Skip to content

A Java library to converts between Japanese Hiragana, Katakana, and Romaji scripts.

Notifications You must be signed in to change notification settings

andree-surya/moji4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moji4J is an open source Java library to converts between Japanese Hiragana, Katakana, and Romaji scripts.

Installation

Please add the following Maven dependency to your pom.xml:

<dependency>
    <groupId>com.andree-surya</groupId>
    <artifactId>moji4j</artifactId>
    <version>1.0.0</version>
</dependency>

Romaji and Kana Conversion

MojiConverter converter = new MojiConverter();

converter.convertRomajiToHiragana("Hiragana"); // ひらがな
converter.convertRomajiToKatakana("Katakana"); // カタカナ
converter.convertKanaToRomaji("ひらがな"); // hiragana
converter.convertKanaToRomaji("カタカナ"); // katakana

Romaji, Kana, and Kanji Detection

MojiDetector detector = new MojiDetector();

detector.hasKanji("まっ暗"); // true
detector.hasKanji("まっしろ"); // false
detector.hasKana("ウソ付き"); // true
detector.hasKana("東京"); // false
detector.hasRomaji("モデル XYZ"); // true
detector.hasRomaji("フルーツ"); // false

Romanization Convention

The romanization system adopted by this library is loosely based on the modern Hepburn system, with adjustments for cases that might causes ambiguity during conversion.

Cases Romaji Kana
Long vowels sentaa センター
ookayama おおかやま
o+u vowels toukyou とうきょう
ousama おうさま
Long consonants kekka けっか
kasetto カセット
kotchi こっち
Syllabic n gunma ぐんま
kan'i かんい
shin'you しんよう
Particles he
wo
Others dzu

Acknowledgement

The romanization tables used in this library are derived from Mojinizer, a Ruby library to converts between Japanese Kana and Romaji. The data is modified to suit differences in algorithm and romanization convention.

License

© Copyright 2016 Andree Surya

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.

About

A Java library to converts between Japanese Hiragana, Katakana, and Romaji scripts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published