Skip to content

Commit

Permalink
支持轻声转换 overtrue#119
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Apr 27, 2023
1 parent 3451f3e commit dc8c4f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ protected function formatTone(string $pinyin, string $style): string
}

$replacements = [
// chr(201) => 'ɑ' 轻声中除了 `ɑ` 和 `ü` 以外,其它和字母一样
'ɑ' => [chr(201), 5], 'ü' => ['v', 5],
'üē' => ['ue', 1], 'üé' => ['ue', 2], 'üě' => ['ue', 3], 'üè' => ['ue', 4],
'ā' => ['a', 1], 'ē' => ['e', 1], 'ī' => ['i', 1], 'ō' => ['o', 1], 'ū' => ['u', 1], 'ǖ' => ['v', 1],
'á' => ['a', 2], 'é' => ['e', 2], 'í' => ['i', 2], 'ó' => ['o', 2], 'ú' => ['u', 2], 'ǘ' => ['v', 2],
Expand Down
4 changes: 4 additions & 0 deletions tests/PinyinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,9 @@ public function test_issues()
//164
$this->assertPinyin(['ōu', 'mǒu', 'mǒu'], Pinyin::name('区某某'));
$this->assertPinyin(['yuè', 'mǒu', 'mǒu'], Pinyin::name('乐某某'));

//119
$this->assertPinyin(['e', 'e', 'e'], Pinyin::sentence('呃呃呃', 'none'));
$this->assertPinyin(['wu', 'la', 'gui'], Pinyin::sentence('乌拉圭', 'none'));
}
}

0 comments on commit dc8c4f4

Please sign in to comment.