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

Contributors 2

  •  
  •