ipapy icon indicating copy to clipboard operation
ipapy copied to clipboard

ipapy behaves strangely when modifing ipachar properties

Open uzytkownik opened this issue 6 years ago • 0 comments

Ipapy by default shares the representation of the characters which leads to strange behaviours:

s = IPAString(unicode_string=r"pæk")
s[0].voicing = 'voiced'
print(s[0].voicing) # voiced
print(s[0].canonical_representation) # bilabial consonant plosive voiceless
print(str(s)) # p
s[2].descriptors = list(map(lambda d: 'voiced' if d in DG_C_VOICING else d, s[2].descriptors))
print(s[2].voicing) # voiced
print(s[2].canonical_representation) # consonant plosive velar voiced
print(str(s)) # k
s = IPAString(unicode_string=r"pæk")
print(s[0].voicing) # voiced

It can be workaround by copying and double-lookup of characters:

s = IPAString(unicode_string=r"pæk")
s[0] = UNICODE_TO_IPA[IPA_TO_UNICODE[IPAChar(descriptors=list(map(lambda d: 'voiced' if d in DG_C_VOICING else d, s[0].descriptors))).canonical_representation]]
print(str(s)) # bæk

But this is very verbose operation for changing a single letter.

uzytkownik avatar Jul 11 '19 05:07 uzytkownik