Skip to content

Commit

Permalink
Add support for wapuro romaji [#issue #8].
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleigh committed Sep 22, 2018
1 parent d51d9b4 commit 037cd19
Show file tree
Hide file tree
Showing 9 changed files with 336 additions and 7 deletions.
60 changes: 60 additions & 0 deletions src/Plugins/Library/Romaji/Lib/Wapuro.php
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',
'' => '.', '' => ',', '' => '?', '' => '!',
'' => '"', '' => '"', ' ' => ' ',
];
2 changes: 1 addition & 1 deletion src/Plugins/Library/Romaji/Styles/KunreiShiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class KunreiShiki extends RomajiConverter
* @var array
*/
protected $tsuConversions = [

//
];

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/Library/Romaji/Styles/NihonShiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NihonShiki extends RomajiConverter
* @var array
*/
protected $particleConversions = [

//
];

/**
Expand All @@ -42,7 +42,7 @@ class NihonShiki extends RomajiConverter
* @var array
*/
protected $tsuConversions = [

//
];

/**
Expand Down
77 changes: 77 additions & 0 deletions src/Plugins/Library/Romaji/Styles/Wapuro.php
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);
}
}
2 changes: 1 addition & 1 deletion tests/Integration/Plugins/Romaji/HepburnModifiedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HepburnModifiedTest extends TestCase
protected static $hepburn;

/**
* Set static Limelight and Hepburn on object.
* Set static hepburn on object.
*/
public static function setUpBeforeClass()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HepburnTraditionalTest extends TestCase
protected static $hepburn;

/**
* Set static Limelight and Hepburn on object.
* Set static hepburn on object.
*/
public static function setUpBeforeClass()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Plugins/Romaji/KunreiShikiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class KunreiShikiTest extends TestCase
protected static $kunrei;

/**
* Set static Limelight and Kunrei on object.
* Set static Kunrei on object.
*/
public static function setUpBeforeClass()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Plugins/Romaji/NihonShikiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NihonShikiTest extends TestCase
protected static $nihon;

/**
* Set static hepburn on object.
* Set static nihon on object.
*/
public static function setUpBeforeClass()
{
Expand Down
192 changes: 192 additions & 0 deletions tests/Integration/Plugins/Romaji/WapuroTest.php
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);
}
}

0 comments on commit 037cd19

Please sign in to comment.