def parse_chinese_morphemes(seq, context=False):
<EOL>if isinstance(seq, list):<EOL><INDENT>tokens = [s for s in seq]<EOL><DEDENT>else:<EOL><INDENT>tokens = lingpy.ipa2tokens(seq, merge_vowels=False)<EOL><DEDENT>arts = [int(x) for x in lingpy.tokens2class(tokens, _art, cldf=True)]<EOL>prostring = lingpy.prosodic_string(arts)<EOL>I,M,N,C,T = '<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>','<STR_LIT>'<EOL>ini = False<EOL>med = False<EOL>nuc = False<EOL>cod = False<EOL>ton = False<EOL>triples = [('<STR_LIT:?>','<STR_LIT:?>','<STR_LIT:?>')]+list(zip(<EOL>tokens,arts,prostring))+[('<STR_LIT:?>','<STR_LIT:?>','<STR_LIT:?>')]<EOL>for i in range(<NUM_LIT:1>,len(triples)-<NUM_LIT:1>): <EOL><INDENT>t,c,p = triples[i]<EOL>_t,_c,_p = triples[i-<NUM_LIT:1>]<EOL>t_,c_,p_ = triples[i+<NUM_LIT:1>]<EOL>if p == '<STR_LIT:A>' and _t == '<STR_LIT:?>':<EOL><INDENT>if t[<NUM_LIT:0>] in '<STR_LIT>':<EOL><INDENT>med = True<EOL>ini,nuc,cod,ton = False,False,False,False<EOL><DEDENT>else:<EOL><INDENT>ini = True<EOL>med,nuc,doc,ton = False,False,False,False<EOL><DEDENT><DEDENT>elif p == '<STR_LIT:X>' and _t == '<STR_LIT:?>':<EOL><INDENT>if t[<NUM_LIT:0>] in '<STR_LIT>' and c_ == '<STR_LIT>':<EOL><INDENT>med = True<EOL>ini,nuc,cod,ton = False,False,False,False<EOL><DEDENT>else:<EOL><INDENT>nuc = True<EOL>ini,med,cod,ton = False,False,False,False<EOL><DEDENT><DEDENT>elif p == '<STR_LIT:C>':<EOL><INDENT>med = True<EOL>ini,nuc,cod,ton = False,False,False,False<EOL><DEDENT>elif p == '<STR_LIT:X>' and p_ == '<STR_LIT:Y>':<EOL><INDENT>if t in '<STR_LIT>':<EOL><INDENT>med = True<EOL>ini,nuc,cod,ton = False,False,False,False<EOL><DEDENT>else:<EOL><INDENT>nuc = True<EOL>ini,med,cod,ton = False,False,False,False<EOL><DEDENT><DEDENT>elif p == '<STR_LIT:X>' or p == '<STR_LIT:Y>':<EOL><INDENT>if p_ in '<STR_LIT>' or p_ == '<STR_LIT:?>':<EOL><INDENT>nuc = True<EOL>ini,med,cod,ton = False,False,False,False<EOL><DEDENT>elif p == '<STR_LIT:Y>':<EOL><INDENT>nuc = True<EOL>ini,med,cod,ton = <NUM_LIT:4> * [False]<EOL><DEDENT>else:<EOL><INDENT>cod = True<EOL>ini,med,nuc,ton = <NUM_LIT:4> * [False]<EOL><DEDENT><DEDENT>elif p == '<STR_LIT:L>':<EOL><INDENT>cod = True<EOL>ini,med,nuc,ton = <NUM_LIT:4> * [False]<EOL><DEDENT>elif p == '<STR_LIT:T>':<EOL><INDENT>ton = True<EOL>ini,med,nuc,cod = <NUM_LIT:4> * [False]<EOL><DEDENT>if ini:<EOL><INDENT>I += t<EOL><DEDENT>elif med:<EOL><INDENT>M += t<EOL><DEDENT>elif nuc:<EOL><INDENT>N += t<EOL><DEDENT>elif cod:<EOL><INDENT>C += t<EOL><DEDENT>else:<EOL><INDENT>T += t<EOL><DEDENT><DEDENT>out = [I,M,N,C,T]<EOL>tf = lambda x: x if x else '<STR_LIT:->'<EOL>out = [tf(x) for x in out]<EOL>tones = dict(zip('<STR_LIT>','<STR_LIT>'))<EOL>ic = '<STR_LIT:1>' if [x for x in I if x in '<STR_LIT>'] else '<STR_LIT:0>'<EOL>mc = '<STR_LIT:1>' if [m for m in M+N if m in '<STR_LIT>'] else '<STR_LIT:0>'<EOL>cc = '<STR_LIT:1>' if C in '<STR_LIT>' else '<STR_LIT:0>'<EOL>tc = '<STR_LIT>'.join([tones.get(x, x) for x in T])<EOL>IC = '<STR_LIT:/>'.join(['<STR_LIT:I>',ic,mc,cc,tc]) if I else '<STR_LIT>'<EOL>MC = '<STR_LIT:/>'.join(['<STR_LIT:M>',ic,mc,cc,tc]) if M else '<STR_LIT>'<EOL>NC = '<STR_LIT:/>'.join(['<STR_LIT:N>',ic,mc,cc,tc]) if N else '<STR_LIT>'<EOL>CC = '<STR_LIT:/>'.join(['<STR_LIT:C>',ic,mc,cc,tc]) if C else '<STR_LIT>'<EOL>TC = '<STR_LIT:/>'.join(['<STR_LIT:T>',ic,mc,cc,tc]) if T else '<STR_LIT>'<EOL>if context:<EOL><INDENT>return out, [x for x in [IC,MC,NC,CC,TC] if x]<EOL><DEDENT>return out<EOL>
Parse a Chinese syllable and return its basic structure.