Package: parsetc
Parsing and conversion of Teochew Chinese romanizationsParse and convert between different Teochew romanized spelling schemes.parsetcrepresents romanization schemes as context-free grammars, and
implements parsers and translators using thelarkPython
library. The aim is to represent romanized text as an abstract parse tree
representing the phonology, which can then be converted to other romanization
schemes in a consistent, rule-based way.Available romanization schemes for TeochewInputGeng'dang Pêng'im 廣東拼音 (gdpi)Gaginang Peng'im 家己儂拼音 (ggn)Gaginang Peng'im with coda-nallowed (nasalization written withñinstead) (ggnn)Dieghv 潮語 (dieghv);(source)Tie-tsiann-hue 潮正會, also known as Tie-lo 潮羅 (tlo);(source)Duffus system (duffus), also known as Pe̍h-ūe-jī (PUJ);(source)Outputgdpi,ggnn,tlo,duffus,dieghv, plus:Teochew Sinwenz (sinwz);(source)Traditional initial-final categories (15) from 《彙集雅俗通十五音》 also
known as 《擊木知音》, based on the analysis by 徐宇航
「《擊木知音》音系之再研究」 (2014)Other languagesThis tool was originally developed for Teochew, but can be extended in the
future to other dialects or languages. An experimental Cantonese module
(--language Cantonese) with Jyutping (jp) and Cantonese Pinyin (cpy) is
available.Orthographic requirements for input textText must be in lower case, otherwise will be converted to lower caseSyllables may be written with or without tone numbersSyllables may be combined into words for legibility, i.e.word-segmented
writingIf syllables are combined into words, they must either have tone numbers
(e.g.diê5ziu1), or use a syllable separator character (e.g.diê-ziuorpêng'im, ordiê5-ziu1). The separator character is either a hyphen or
single apostrophe. This is because of ambiguous parsings, e.g.pê-ngi-minstead ofpêng-im, which in general can only be dealt with by usage
frequency, which is not available.If syllable separator characters are used, they must be used consistently.
Mixing conventions may cause unexpected parsing errors.Installationparsetcrequires Python 3 andlarkv1.1.Install latest release withpipfrom PyPI:pipinstallparsetcIf you are interested in latest development version, you can clone this
repository and checkout thedevbranch, then install withpipfrom source
code:pipinstall.See help message:parsetc--helpView available input and output schemes for Teochew:parsetc--languageTeochew--show_optionsUsageCommand line toolInput text is read line-by-line from STDIN. Output is written to STDOUT.The language (--languageor-l) isTeochewby default.# Convert to Tie-loecho'ua2 ain3 oh8 diê5ghe2, ain3 dan3 diê5ziu1 uê7.'|parsetc-igdpi-otlo# Convert to all available output romanizationsecho'ua2 ain3 oh8 diê5ghe2, ain3 dan3 diê5ziu1 uê7.'|parsetc-igdpi--all# Show parse tree (useful for debugging)echo'ua2 ain3 oh8 diê5ghe2, ain3 dan3 diê5ziu1 uê7.'|parsetc-igdpi-pTesting with sample texts in theexamples/folder:# Example with tone numbers but no syllable separatorscatexamples/teochew.dieghv.tones.txt|parsetc-idieghv--all# Example with hyphens as syllable separatorscatexamples/teochew.dieghv.sep.txt|parsetc-idieghv--allTry a Cantonese example (work in progress):echo"ceon1 min4 bat1 gok3 hiu2"|parsetc-lCantonese-ijp--all
catexamples/cantonese.cpy.txt|parsetc-lCantonese-icpy--allPython module[ Work in progress. Updated docs coming soon... ]Common functions and command line script are in theparsetc.parsetcsubmodule. Each language has a dedicated subpackage with the following
structure (using Teochew as an example):src/parsetc/Teochew/
├── shared.lark     # lark grammar for shared parser rules
├── extends.json    # lark %extend statements specific to individual schemes
├── terminals.json  # dictionary of terminals for each scheme
├── mergers.json    # dictionary of phonological mergers specific to individual schemes
├── parser.py       # preprocessing and parser functions
└── translit.py     # Translator classesThe lark rules and json files are the data required for the parsing and
translation functions inparser.pyandtranslit.py.Q & AQ: Can I convert Chinese characters to romanization withparsetc?A: No, it is for converting between different romanization systems only.Q:parsetcmakes a mistake, or it crashes when parsing a text. Can you fix it?A: Please check first if you are using the latest version ofparsetc(runparsetc --version). If the error still persists, please file a bug report
on the Githubissuespage,
with the input text that caused the crash/error.Q: Can I contribute code to this project?A: You are welcome to look into the source code and fork/modfiy it. However,
I currently do not have the capacity to review pull requests and
contributions in detail, so please understand if I decline them or take a
long time to respond.Related projectsFrom Learn-TeochewWe useparsetcto convert Teochew opera transcriptions into different
romanization systems for theLearn Teochew
Operawebsite.How to type the special diacritics likeṳ, o̍, o͘in some romanization systems?
If you use MacOS X, check out ourcustom keyboard
layoutsOtherstaibun- Transliterator and tokenizer
for Taiwanese Hokkien by Andrei Harbachov