# remove frequency supplements from HanyuPinlu entries
/	kHanyuPinlu	/ s,([^)]*),,g

# replace tags with number (for sorting) and shortcut
s,	kMandarin,	1 M,
s,	kCantonese,	2 C,
s,	kJapaneseKun,	3 J,
s,	kJapaneseOn,	4 S,
s,	kKorean,	5 K,
s,	kVietnamese,	6 V,
s,	kHanyuPinlu,	7 P,
s,	kTang,	8 T,
s,	kDefinition,	9 D,
t cont
d

# U+4E0B  kHanyuPinlu     xia4(6430) xia5(249)

: cont
# format code value to uniform length for subsequent sorting
s,U+\(....\)	,U+0\1	,

# fix missing space around parentheses
s,\([^	 (]\)(\([^)]* [^)]* \),\1 (\2,g
s,)\([^ ]\),) \1,g
# fix incorrect ((
s,((\([^)]*)[^)]*\)$,(\1,
# fix superfluous blanks before , or ;
s/ ,/,/g
s/ ;/;/g
