thebesttv / pinyinlib.el

Elisp library for converting first letter of Pinyin to Simplified/Traditional Chinese characters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pinyinlib.el

https://melpa.org/packages/pinyinlib-badge.svg https://stable.melpa.org/packages/pinyinlib-badge.svg

Library for converting first letter of Pinyin to Simplified/Traditional Chinese characters.

改用小鹤双拼而非拼音

gen.py 使用 =pinyin-data= 的数据生成小鹤双拼字典 shuangpin-dict.el. pinyinlib.el 会加载双拼字典. 依赖:

pip install Unidecode OpenCC

Functions

pinyinlib-build-regexp-char

pinyinlib-build-regexp-char converts a letter to a regular expression containing all the Chinese characters whose pinyins start with the letter. It accepts four parameters:

char &optional no-punc-p tranditional-p only-chinese-p

The first parameter char is the letter to be converted. The latter three parameters are optional.

  • If no-punc-p is t: it will not convert English punctuations to Chinese punctuations.
  • If traditional-p is t: traditional Chinese characters are used instead of simplified Chinese characters.
  • If only-chinese-p is t: the resulting regular expression doesn’t contain the English letter char.

When converting English punctuactions to Chinese/English punctuations, it uses the following table:

English PunctuationChinese & English Punctuations
.。.
,,,
???
:::
!!!
;;;
\、\
(((
)))
<《<
>》>
~~~
‘’「」’
“”『』"
*×*
$¥$

pinyinlib-build-regexp-string

It is same as pinyinlib-build-regexp-char, except that its first parameter is a string so that it can convert a sequence of letters to a regular expression.

Packages that Use This Library

Acknowledgment

Contribute

Contributions are always welcome. If you want to add some common pinyin related functions that might be useful for other packages, please send me a PR.

About

Elisp library for converting first letter of Pinyin to Simplified/Traditional Chinese characters


Languages

Language:Emacs Lisp 94.9%Language:Python 5.1%