def mark_spaces(NTags): Str='' WPs=myModule.flatten_list(NTags) LstWP=('','') # and this is WC level for (Cntr,NTag) in enumerate(NTags): # if Debug: sys.stdout.write('Up to WC'+str(Cntr+1)) # this part is to determine whether the space between two wcs is optional or not # so, the first one is ignored, if Cntr==0: Space='' # and from the second one, the top tag of it and the last tag of the previous one are compared else: if optional_space_p(LstWP,NTag[0]): Space=' '+ZWNJ else: Space=' ' # and this is the intra-WC part WCStr=mark_intrawc(NTag) # then mark the space plus the WC accordingly Str=Str+Space+WCStr # if Debug and Cntr==len(NTags)-1: # sys.stdout.write('Marked: '); print([Str]) # the last one of the current tag is stored as the 'previous' tag LstWP=NTag[-1] return (Str,WPs)
def normalisation_ok_p(WC_WPs,NWPs): OrgStr=''.join([ WC_WP[0] for WC_WP in WC_WPs ]) NewStr=''.join([ WP[0] for WP in myModule.flatten_list(NWPs) ]) if OrgStr==NewStr: Bool=True else: Bool=False return Bool