Skip to content
/ pinyin Public
forked from overtrue/pinyin

基于词库的中文转拼音优质解决方案

License

Notifications You must be signed in to change notification settings

abaowu/pinyin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pinyin

Chinese to pinyin translator based on CC-CEDICT.

usage

$py = new Pinyin('./dict/cedict_ts.u8');
echo $py->trans('带着希望去旅行,比到达终点更美好');

// dài zhe xī wàng qu lǚ xíng , bǐ dào dá zhōng diǎn gèng měi hǎo

setting

  • delimiter Separator between each pinyin, default is a space ' '.
  • accent Whether the output tone.
<?php
$setting = [
			'delimiter' => '-',
		   ];
$py = new Pinyin('./dict/cedict_ts.u8', $setting);
echo $py->trans('带着希望去旅行,比到达终点更美好');

// dài-zhe-xī-wàng-qu-lǚ-xíng-bǐ-dào-dá-zhōng-diǎn-gèng-měi-hǎo
<?php
$setting = [
			'delimiter' => '-',
			'accent' => false,
		   ];
$py = new Pinyin('./dict/cedict_ts.u8', $setting);
echo $py->trans('带着希望去旅行,比到达终点更美好');

// dai-zhe-xi-wang-qu-lu-xing-bi-dao-da-zhong-dian-geng-mei-hao
$setting = [
			'accent' => false,
		   ];
$py = new Pinyin('./dict/cedict_ts.u8', $setting);
echo $py->trans('带着希望去旅行,比到达终点更美好');

// dai zhe xi wang qu lu xing bi dao da zhong dian geng mei hao

License

MIT

About

基于词库的中文转拼音优质解决方案

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%