% Move tones to end of word
(?P<sw1>[˩˨˧˦˥]+)(?P<sw2>\w+) -> 0 / _\b

% glottal stop - could already in end in 8th tone
h -> ʔ / _ #
h -> ʔ / _ ˥ #

% neutral tone. create artificial marker that prevents the following rules from applying
% if the word already had a tone, it is unaffected
-- -> 輕 / # _
(?P<sw1>輕)(?P<sw2>[^輕]+) -> 0 / _

% the following rules rely on the tone already being moved to the end of the word
% ends in h,p,t,k and does not have a tone diacritic - 4th tone
% and does not start with --
0 -> ˧ / [ʔptk] _ #

% if no tone diacritic and does not end in a stop - 1st tone
% ensure it is not neutral tone either (i.e. beginning with --)
0 -> ˥ / ([^˩˨˧˦˥輕]) _ #

% remove artificial neutral tone marker
輕 -> 0 / _ #
