8 """! @package utils.ipa2sampa
11 from __future__
import print_function,unicode_literals
16 data = codecs.open(
'./pylmflib/utils/ipa2sampa/sampa.csv',
'r', 'utf-8')
22 if not line.strip()
or line.startswith(
'#'):
25 so,ta = unicodedata.normalize(
"NFD",line.strip()).split(
'\t')
27 ta = eval(
'"""'+ta+
'"""')
31 sota = dict([(b,a)
for a,b
in sota])
35 Convert sequence in unicode-ipa to ascii-sampa.
39 Forked from LingPy's version for ipa2sampa, which is based on code
40 taken from Peter Kleiweg
41 (http://www.let.rug.nl/~kleiweg/L04/devel/python/xsampa.html).
44 if type(sequence) == str:
45 sequence = unicode(sequence,
'utf-8')
47 seq = [k
for k
in unicodedata.normalize(
'NFD', sequence)]
58 if __name__ ==
'__main__':
60 with codecs.open(
'./pylmflib/utils/ipa2sampa/tokens.test',
'r','utf-8') as f: