Skip to main content

pinyin-dec

pinyin-dec (“Pinyin Decorate”) is a small command-line utility program for converting numbered Pinyin text to its proper form with diacritics. The basic form is the following:

Usage: pinyin-dec [options] [string ...]

Decorate Pinyin text with its proper diacritics.

Options:
  -h, --help       print this help message and exit
  -v, --verbose    include information useful for debugging

A simple way to use it is like this:

$ pinyin-dec han4 yu3 pin1 yin1
hàn yǔ pīn yīn

Another example:

$ pinyin-dec chai2 mi3 you2 yan2 jiang4 cu4 cha2
chái mǐ yóu yán jiàng cù chá

It can also handle capitalized and conjoined Pinyin automatically:

$ pinyin-dec Han4yu3 Pin1yin1
Hànyǔ Pīnyīn

It knows about the “v” and “u:” conventions, and converts them accordingly:

$ pinyin-dec NV3 nv3 NU:3 nu:3 LV4 lv4 LU:4 lu:4
NǙ nǚ NǙ nǚ LǛ lǜ LǛ lǜ

It ignores English words and other things that don’t look like Pinyin:

$ pinyin-dec "She is a nv3han4zi."
She is a nǚhànzi.

It leaves punctuation alone too, as you can see:

$ pinyin-dec 'Confucius is "Kong3fu1zi3." Mencius is "Meng4zi3."'
Confucius is "Kǒngfūzǐ." Mencius is "Mèngzǐ."

If no arguments are given, it just reads text from the standard input:

$ echo 'Sha1 ji1 xia4 hou2.' | pinyin-dec
Shā jī xià hóu.

It also allows you to enter text and get the results one line at a time:

$ pinyin-dec
chi1 bu4 dao4 pu2 tao5 shuo1 pu2 tao5 suan1
chī bù dào pú tao shuō pú tao suān

pinyin-dec is written as a traditional Unix-style command-line utility. Additionally, the main program module can be fully imported into Python so its internals are accessible to other programs.

pinyin-dec is written in Python 3 and available under the MIT License.

Installation

To install these programs the “Python way,” you can use setup.py:

# python3 setup.py install

If you have pip installed, that is the best way.

Documentation

pinyin-dec includes a Unix manual page (“manpage”), which is installed with the software. You can type “man pinyin-dec” to review the functions provided by the software, how to use it, and other program information.

Metadata

Release files for pinyin-dec 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pinyin-dec 1.0.1
File Size Uploaded Provenance Actions
pinyin-dec-1.0.1.tar.gz 6.5 kB Without provenance Details for pinyin-dec-1.0.1.tar.gz

Release files / pinyin-dec-1.0.1.tar.gz

Download URL pinyin-dec-1.0.1.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
49eb80d486b62fba26c36630f5bd645d1beadca2801aec92905c47f3d88f1738
BLAKE2b-256 checksum
How to use checksums
b87934f03f02bc2878c223d2249711db917b2a7f1b63bf2d6ad27ca9b476f56d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pinyin-dec 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page