Ejemplo n.º 1
0
def i2a(ipastring):
    """Convert an IPA string to an arpabet string.

    Args:
        ipastring: A string representing ipa using utf-8 encoding.
    Returns:
        arpabetstring: A list representing the corresponding arpabet.

    """
    amapper = ARPABETMapper()
    arpastring = amapper.map_unicode_string(ipastring,
                                            ignore=True,
                                            return_as_list=True)
    return arpastring
Ejemplo n.º 2
0
 def test_map_unicode_string_single(self):
     mapper = ARPABETMapper()
     values = [
         (u"", u""),
         (u"p", u"P"),
         (u"p\u03B8", u"PTH"),
         (u"\u027E", u"DX"),
         (u"p\u0258\u026A", u"PEY"),
         (u"p\u0258\u026Aw", u"PEYW"),
         (u"p\u0258\u026A\u0258\u026Aw", u"PEYEYW"),
         (u"p\u0258\u026A\u0251w", u"PEYAAW"),
         (u"\u006A\u0075", u"YUW"),
     ]
     for v, e in values:
         self.assertEqual(mapper.map_unicode_string(v, single_char_parsing=True), e)
Ejemplo n.º 3
0
 def test_map_unicode_string(self):
     mapper = ARPABETMapper()
     values = [
         (None, None),
         (u"", u""),
         (u"p", u"P"),
         (u"p\u03B8", u"PTH"),
         (u"\u027E", u"DX"),
         (u"p\u0258\u026A", u"PEY"),
         (u"p\u0258\u026Aw", u"PEYW"),
         (u"p\u0258\u026A\u0258\u026Aw", u"PEYEYW"),
         (u"p\u0258\u026A\u0251w", u"PEYAAW"),
         (u"\u006A\u0075", u"YUW"),
     ]
     for v, e in values:
         self.assertEqual(mapper.map_unicode_string(v), e)
Ejemplo n.º 4
0
 def test_map_unicode_string_ignore(self):
     mapper = ARPABETMapper()
     values = [
         (None, None),
         (u"", u""),
         (u"p", u"P"),
         (u"p\u03B8", u"PTH"),
         (u"\u027E", u"DX"),
         (u"p\u0258\u026A", u"PEY"),
         (u"p\u0258\u026Aw", u"PEYW"),
         (u"p\u0258\u026A\u0258\u026Aw", u"PEYEYW"),
         (u"p\u0258\u026A\u0251w", u"PEYAAW"),
         (u"\u006A\u0075", u"YUW"),
         (u"a\u006A\u0075", u"AEYUW"),
         (u"o\u006A\u0075", u"OHYUW"),
         (u"S\u006A\u0075", u"YUW"),
         (u"S\u006A\u0075\u02C8be", u"YUWBEH"),
     ]
     for v, e in values:
         self.assertEqual(mapper.map_unicode_string(v, ignore=True), e)
Ejemplo n.º 5
0
 def test_map_unicode_string_ignore(self):
     mapper = ARPABETMapper()
     values = [
         (None, None),
         (u"", u""),
         (u"p", u"P"),
         (u"p\u03B8", u"PTH"),
         (u"\u027E", u"DX"),
         (u"p\u0258\u026A", u"PEY"),
         (u"p\u0258\u026Aw", u"PEYW"),
         (u"p\u0258\u026A\u0258\u026Aw", u"PEYEYW"),
         (u"p\u0258\u026A\u0251w", u"PEYAAW"),
         (u"\u006A\u0075", u"YUW"),
         (u"a\u006A\u0075", u"AEYUW"),
         (u"o\u006A\u0075", u"OHYUW"),
         (u"S\u006A\u0075", u"YUW"),
         (u"S\u006A\u0075\u02C8be", u"YUWBEH"),
     ]
     for v, e in values:
         self.assertEqual(mapper.map_unicode_string(v, ignore=True), e)