-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for wapuro romaji [#issue #8].
- Loading branch information
Showing
9 changed files
with
336 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
return [ | ||
'あ' => 'a', 'い' => 'i', 'う' => 'u', 'え' => 'e', 'お' => 'o', | ||
'か' => 'ka', 'き' => 'ki', 'く' => 'ku', 'け' => 'ke', 'こ' => 'ko', | ||
'が' => 'ga', 'ぎ' => 'gi', 'ぐ' => 'gu', 'げ' => 'ge', 'ご' => 'go', | ||
'さ' => 'sa', 'し' => 'shi', 'す' => 'su', 'せ' => 'se', 'そ' => 'so', | ||
'ざ' => 'za', 'じ' => 'zi', 'ず' => 'zu', 'ぜ' => 'ze', 'ぞ' => 'zo', | ||
'た' => 'ta', 'ち' => 'chi', 'つ' => 'tsu', 'て' => 'te', 'と' => 'to', | ||
'だ' => 'da', 'ぢ' => 'di', 'づ' => 'du', 'で' => 'de', 'ど' => 'do', | ||
'な' => 'na', 'に' => 'ni', 'ぬ' => 'nu', 'ね' => 'ne', 'の' => 'no', | ||
'は' => 'ha', 'ひ' => 'hi', 'ふ' => 'fu', 'へ' => 'he', 'ほ' => 'ho', | ||
'ば' => 'ba', 'び' => 'bi', 'ぶ' => 'bu', 'べ' => 'be', 'ぼ' => 'bo', | ||
'ぱ' => 'pa', 'ぴ' => 'pi', 'ぷ' => 'pu', 'ぺ' => 'pe', 'ぽ' => 'po', | ||
'ま' => 'ma', 'み' => 'mi', 'む' => 'mu', 'め' => 'me', 'も' => 'mo', | ||
'や' => 'ya', 'ゆ' => 'yu', 'よ' => 'yo', | ||
'ら' => 'ra', 'り' => 'ri', 'る' => 'ru', 'れ' => 're', 'ろ' => 'ro', | ||
'わ' => 'wa', 'うぃ' => 'whi', 'うぇ' => 'whe', 'を' => 'wo', | ||
'ゑ' => 'we', 'ゐ' => 'wi', 'ー' => '-', 'ん' => 'n', | ||
'きゃ' => 'kya', 'きゅ' => 'kyu', 'きょ' => 'kyo', 'きぇ' => 'kye', 'きぃ' => 'kyi', | ||
'きゅう' => 'kyuu', 'きょう' => 'kyou', | ||
'ぎゃ' => 'gya', 'ぎゅ' => 'gyu', 'ぎょ' => 'gyo', 'ぎぇ' => 'gye', 'ぎぃ' => 'gyi', | ||
'ぎゅう' => 'gyuu', 'ぎょう' => 'gyou', | ||
'くぁ' => 'kwa', 'くぃ' => 'kwi', 'くぅ' => 'kwu', 'くぇ' => 'kwe', 'くぉ' => 'kwo', | ||
'ぐぁ' => 'qwa', 'ぐぃ' => 'gwi', 'ぐぅ' => 'gwu', 'ぐぇ' => 'gwe', 'ぐぉ' => 'gwo', | ||
'しゃ' => 'sha', 'しぃ' => 'syi', 'しゅ' => 'shu', 'しぇ' => 'she', 'しょ' => 'sho', | ||
'しゅう' => 'shuu', 'しょう' => 'shou', | ||
'じゃ' => 'ja', 'じゅ' => 'ju', 'じぇ' => 'jye', 'じょ' => 'jo', 'じぃ' => 'jyi', | ||
'じゅう' => 'juu', 'じょう' => 'jou', | ||
'すぁ' => 'swa', 'すぃ' => 'swi', 'すぅ' => 'swu', 'すぇ' => 'swe', 'すぉ' => 'swo', | ||
'ちゃ' => 'cha', 'ちゅ' => 'chu', 'ちぇ' => 'tye', 'ちょ' => 'cho', 'ちぃ' => 'tyi', | ||
'ちゅう' => 'chuu', 'ちょう' => 'chou', | ||
'ぢゃ' => 'ja', 'ぢぃ' => 'dyi', 'ぢゅ' => 'ju', 'ぢぇ' => 'dye', 'ぢょ' => 'jo', | ||
'つぁ' => 'tsa', 'つぃ' => 'tsi', 'つぇ' => 'tse', 'つぉ' => 'tso', 'てゃ' => 'tha', | ||
'てぃ' => 'thi', 'てゅ' => 'thu', 'てぇ' => 'the', 'てょ' => 'tho', 'とぁ' => 'twa', | ||
'とぃ' => 'twi', 'とぅ' => 'twu', 'とぇ' => 'twe', 'とぉ' => 'two', 'でゃ' => 'dha', | ||
'でぃ' => 'dhi', 'でゅ' => 'dhu', 'でぇ' => 'dhe', 'でょ' => 'dho', 'どぁ' => 'dwa', | ||
'どぃ' => 'dwi', 'どぅ' => 'dwu', 'どぇ' => 'dwe', 'どぉ' => 'dwo', | ||
'にゃ' => 'nya', 'にゅ' => 'nyu', 'にょ' => 'nyo', 'にぇ' => 'nye', 'にぃ' => 'nyi', | ||
'にゅう' => 'nyuu', 'にょう' => 'nyou', | ||
'ひゃ' => 'hya', 'ひぃ' => 'hyi', 'ひゅ' => 'hyu', 'ひぇ' => 'hye', 'ひょ' => 'hyo', | ||
'ひゅう' => 'hyuu', 'ひょう' => 'hyou', | ||
'びゃ' => 'bya', 'びぃ' => 'byi', 'びゅ' => 'byu', 'びぇ' => 'bye', 'びょ' => 'byo', | ||
'びゅう' => 'byuu', 'びょう' => 'byou', | ||
'ぴゃ' => 'pya', 'ぴぃ' => 'pyi', 'ぴゅ' => 'pyu', 'ぴぇ' => 'pye', 'ぴょ' => 'pyo', | ||
'ぴゅう' => 'pyuu', 'ぴょう' => 'pyou', | ||
'ふぁ' => 'fwa', 'ふぃ' => 'fyi', 'ふぇ' => 'fye', 'ふぉ' => 'fwo', 'ふぅ' => 'fwu', | ||
'ふゃ' => 'fya', 'ふゅ' => 'fyu', 'ふょ' => 'fyo', 'みゃ' => 'mya', 'みぃ' => 'myi', | ||
'みゅ' => 'myu', 'みぇ' => 'mye', 'みょ' => 'myo', 'りゃ' => 'rya', 'りぃ' => 'ryi', | ||
'みゅう' => 'myuu', 'みょう' => 'myou', | ||
'りゅ' => 'ryu', 'りぇ' => 'rye', 'りょ' => 'ryo', | ||
'りゅう' => 'ryuu', 'りょう' => 'ryou', | ||
'ゔぁ' => 'va', 'ゔぃ' => 'vyi', 'ゔ' => 'vu', 'ゔぇ' => 'vye', 'ゔぉ' => 'vo', | ||
'ゔゃ' => 'vya', 'ゔゅ' => 'vyu', 'ゔょ' => 'vyo', | ||
'うぁ' => 'wha', 'いぇ' => 'ye', 'うぉ' => 'who', | ||
'ぁ' => 'xa', 'ぃ' => 'xi', 'ぅ' => 'xu', 'ぇ' => 'xe', 'ぉ' => 'xo', | ||
'ゕ' => 'xka', 'ゖ' => 'xke', 'ゎ' => 'xwa', | ||
'。' => '.', '、' => ',', '?' => '?', '!' => '!', | ||
'「' => '"', '」' => '"', ' ' => ' ', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ class KunreiShiki extends RomajiConverter | |
* @var array | ||
*/ | ||
protected $tsuConversions = [ | ||
|
||
// | ||
]; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Limelight\Plugins\Library\Romaji\Styles; | ||
|
||
use Limelight\Plugins\Library\Romaji\RomajiConverter; | ||
|
||
class Wapuro extends RomajiConverter | ||
{ | ||
/** | ||
* Romaji library. | ||
* | ||
* @var array | ||
*/ | ||
protected $conversions; | ||
|
||
/** | ||
* Conversions for 'n'. | ||
* | ||
* @var array | ||
*/ | ||
protected $nConversions = [ | ||
'a' => 'nn', | ||
'i' => 'nn', | ||
'u' => 'nn', | ||
'e' => 'nn', | ||
'o' => 'nn', | ||
'y' => 'nn', | ||
]; | ||
|
||
/** | ||
* Conversions for particles. | ||
* | ||
* @var array | ||
*/ | ||
protected $particleConversions = [ | ||
// | ||
]; | ||
|
||
/** | ||
* Conversions for small tsu. | ||
* | ||
* @var array | ||
*/ | ||
protected $tsuConversions = [ | ||
// | ||
]; | ||
|
||
/** | ||
* Acceptable verb combinations. | ||
* | ||
* @var array | ||
*/ | ||
protected $verbCombos = [ | ||
// | ||
]; | ||
|
||
/** | ||
* Construct. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->conversions = include dirname(__DIR__) . '/Lib/Wapuro.php'; | ||
} | ||
|
||
/** | ||
* handle conversion request. | ||
* | ||
* @param string $string | ||
* @param LimelightWord $word | ||
* | ||
* @return string | ||
*/ | ||
public function handle($string, $word) | ||
{ | ||
return $this->convert($string, $word); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
<?php | ||
|
||
namespace Limelight\tests\Integration\Plugins\Romaji; | ||
|
||
use Limelight\Tests\TestCase; | ||
use Limelight\Plugins\Library\Romaji\Styles\Wapuro; | ||
|
||
class WapuroTest extends TestCase | ||
{ | ||
/** | ||
* @var Limelight\Plugins\Library\Romaji\Styles\Wapuro | ||
*/ | ||
protected static $wapuro; | ||
|
||
/** | ||
* Set static wapuro on object. | ||
*/ | ||
public static function setUpBeforeClass() | ||
{ | ||
parent::setUpBeforeClass(); | ||
|
||
self::$wapuro = new Wapuro(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_simple_word_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('行きます'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('ikimasu', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_nn_word_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('参加'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('sanka', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_simple_double_vowel_word_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('お兄さん'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('oniisan', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_sho_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('初夏'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('shoka', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_long_o_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('証券'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('shouken', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_kyou_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('今日'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('kyou', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_multiple_words_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('福岡に住んでいます。'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('Fukuokanisundeimasu.', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_double_k_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('結果'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('kekka', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_double_c_to_romaji() | ||
{ | ||
$results = self::$limelight->parse('抹茶'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('maccha', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_doesnt_convert_nm() | ||
{ | ||
$results = self::$limelight->parse('群馬'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('Gunma', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_converts_n_vowel_to_nn() | ||
{ | ||
$results = self::$limelight->parse('簡易'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('kanni', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_doesnt_convert_long_vowels_not_listed() | ||
{ | ||
$results = self::$limelight->parse('お婆さん'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('obaasan', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_doesnt_convert_ha_to_wa() | ||
{ | ||
$results = self::$limelight->parse('は'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('ha', $conversion); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_doesnt_convert_he_to_e() | ||
{ | ||
$results = self::$limelight->parse('へ'); | ||
|
||
$conversion = $this->getRomajiConversion(self::$wapuro, $results); | ||
|
||
$this->assertEquals('he', $conversion); | ||
} | ||
} |