2017 © Pedro Peláez
 

library pinyin

Romanization tool for Traditional Chinese

image

thl/pinyin

Romanization tool for Traditional Chinese

  • Thursday, March 30, 2017
  • by thlgrant
  • Repository
  • 2 Watchers
  • 7 Stars
  • 377 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

PHP 華語拼音轉換工具

將字串中之漢字視為華語,並轉換成各種拼音形式之工具, (*1)

支援拼音法

  • 注音拼音 (Bopomofo)
  • 臺灣華語羅馬拼音 (THL)
  • 漢語拼音
  • 通用拼音
  • 注音二式
  • 威妥瑪拼音

安裝方式

建議使用 php-composer 安裝, (*2)

composer require thl/pinyin

使用說明

Pinyin::bpmf()

將字串內漢字以華語注音符號表示, (*3)

string THL\Pinyin::bpmf(string $source)
參數
  • $source 輸入字串
範例
// returns "THL ㄊㄞˊ ㄨㄢ ㄏㄨㄚˊ ㄩˇ ㄌㄨㄛˊ ㄇㄚˇ ㄆㄧㄣ ㄧㄣ"
$output = THL\Pinyin::bpmf("THL台灣華語羅馬拼音");

Pinyin::pinyin()

將字串內漢字以華語拼音表示, (*4)

string THL\Pinyin::pinyin(string $source, array $options)
參數
  • $source 輸入字串
  • $options 參數
    • notation: 方案,預設為 thl
    • thl (台灣華語羅馬拼音)
    • hy (漢語拼音)
    • ty (通用拼音)
    • mps2 (注音二式)
    • wg (威妥瑪拼音)
    • tone: 聲調,預設為 number
    • number (數字表示)
    • mark (符號表示) 目前暫時只支援臺灣華語羅馬拼音 (THL)
    • none (無聲調)
    • split: 分割,預設為 word
    • word (單字)
    • phrase (詞)
範例
// returns "THL tai2 wan1 hua2 yu3 luo2 ma3 pin1 yin1"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音");

// returns "THL taíwan huáyǔ luómǎ pinyin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('tone' => 'mark', 'split' => 'phrase'));

// returns "THL t'ai wan hua yü lo ma p'in yin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('notation' => 'wg', 'tone' => 'none', 'split' => 'word'));

Pinyin::slug()

產生適合當網址的格式, (*5)

string THL\Pinyin::slug(string $source, array $options)
參數
  • $source 輸入字串
  • $options 參數
    • notation: 方案,預設為 thl
    • thl (台灣華語羅馬拼音)
    • hy (漢語拼音)
    • ty (通用拼音)
    • mps2 (注音二式)
    • wg (威妥瑪拼音)
    • tone: 聲調,預設為 none
    • number (數字表示)
    • none (無聲調)
    • split: 分割,預設為 word
    • word (單字)
    • phrase (詞)
範例
// returns "thl-tai-wan-hua-yu-luo-ma-pin-yin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音");

// returns "thl-taiwan-huayu-luoma-pinyin"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('split' => 'phrase'));

// returns "thl-tai2wan1-hua2yu3-luo2ma3-pin1yin1"
$output = THL\Pinyin::pinyin("THL台灣華語羅馬拼音", array('notation' => 'ty', 'tone' => 'number', 'split' => 'phrase'));

詞庫

詞庫的部份以小麥注音為基礎,字的部份另外使用cconv 翻譯成簡體漢字, (*6)

  • 由於詞庫部份尚未翻譯為中式華語,以簡體漢字書寫之句子有大部份的情況會被視為獨立單字組成

The Versions

30/03 2017

dev-master

9999999-dev

Romanization tool for Traditional Chinese

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Wei-Hao Syu

pinyin chinese bopomofo

15/03 2016

1.2

1.2.0.0

Romanization tool for Traditional Chinese

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Wei-Hao Syu

pinyin chinese bopomofo

22/10 2015

1.1

1.1.0.0

Romanization tool for Traditional Chinese

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Wei-Hao Syu

pinyin chinese bopomofo

20/05 2015

1.0

1.0.0.0

Romanization tool for Traditional Chinese

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Wei-Hao Syu

pinyin chinese bopomofo