Skip to content

Convert between different representations of Hànyǔ Pīnyīn.

License

Notifications You must be signed in to change notification settings

sinostudy/pinyin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sino·study Pinyin

Sino·study Pinyin

This is a small Clojure/ClojureScript library for converting between different styles of Hànyǔ Pīnyīn, the system of romanization used for Standard Chinese in the PRC. It doesn't have any external dependencies.

You can use it to convert back and forth between the standard Pīnyīn representation that uses tone diacritics and the more informal one that uses digits to represent tones. You can also remove tone digits or diacritics entirely, creating a plain ASCII representation useful for normalising syllables when implementing e.g. indexing/search.

Some additional things worth noting:

  • The neutral tone is represented as 0 or 5 (or left out entirely) if using digits to write tones.
  • Like in many Pīnyīn input methods, a V is treated as a Pīnyīn Ü.
  • The non-standard Pīnyīn M is supported (as found in e.g. cc-cedict).
  • The very common érhuà-style final R is supported as well.

Example usage

(use 'study.sino.pinyin)

(digits->diacritics "ni3hao3, ni3 shi4 shei2?")  ; => "nǐhǎo, nǐ shì shéi?"
(diacritics->digits "nǐhǎo, nǐ shì shéi?")       ; => "ni3hao3, ni3 shi4 shei2?"

(no-digits "ni3hao3, ni3 shi4 shei2?")           ; => "nihao, ni shi shei?"
(no-diacritics "nǐhǎo, nǐ shì shéi?")            ; => "nihao, ni shi shei?"

About

Convert between different representations of Hànyǔ Pīnyīn.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published