def test(self): """ class TestClone """ ph1 = PhoSegObject( ipa="tˈai̯˧˥papo" ) ph2 = ph1.clone() self.assertEqual( ph1.get_ipa_representation(), ph2.get_ipa_representation() ) ph1[0].onset[0].maindata[0]['length'].set_to_extralong() self.assertNotEqual( ph1.get_ipa_representation(), ph2.get_ipa_representation() )
def test_endswith(self): """ TestPhoseg.test_endswith """ phoseg1 = PhoSegObject( ipa = "tʰːapi" ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "pi" ) self.assertEqual( phoseg1.endswith(phoseg2), True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "" ) self.assertEqual( phoseg1.endswith(phoseg2), True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "tʰːapi" ) self.assertEqual( phoseg1.endswith(phoseg2), True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "iː" ) self.assertEqual( phoseg1.endswith(phoseg2), False ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . # a more complex case : the final -n is in the coda of <phoseg1> but in # the onset of <phoseg2> phoseg1 = PhoSegObject( ipa = "tʰːapin" ) phoseg2 = PhoSegObject( ipa = "n" ) self.assertEqual( phoseg1.endswith(phoseg2), True )
def test_startswith(self): """ TestPhoseg.test_startswith """ phoseg1 = PhoSegObject( ipa = "tʰːapi" ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "tʰːa" ) self.assertEqual( phoseg1.startswith(phoseg2), True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "" ) self.assertEqual( phoseg1.startswith(phoseg2), True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "tʰːapi" ) self.assertEqual( phoseg1.startswith(phoseg2), True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . phoseg2 = PhoSegObject( ipa = "pʰ" ) self.assertEqual( phoseg1.startswith(phoseg2), False )
def test_init_by_ipa_string(self): """ TestPhoseg.test_init_by_ipa_string """ # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( len(phosegobj), 0 ) self.assertEqual( phosegobj.initialization_ok, True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "t" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( len(phosegobj), 1 ) self.assertEqual( phosegobj.initialization_ok, True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "ʰtː" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( len(phosegobj), 1 ) self.assertEqual( phosegobj.initialization_ok, True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "ʰtːa" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( len(phosegobj), 1 ) self.assertEqual( phosegobj.number_of_phonemes(), 2 ) self.assertEqual( phosegobj.initialization_ok, True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "ʰtːapi" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( len(phosegobj), 2 ) self.assertEqual( phosegobj.number_of_phonemes(), 4 ) self.assertEqual( phosegobj.initialization_ok, True ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "ʰtːa²pi" with self.assertRaises(Exception): phosegobj = PhoSegObject( ipa = ipastring )
def test_init_by_soundsnames(self): """ TestPhoseg.test_init_by_soundsnames """ # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = ['voiced palatal approximant'] ) self.assertEqual( ph_obj.get_ipa_representation(), "j") # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = \ ['low front unrounded to close front unrounded diphthong'] ) self.assertEqual( ph_obj.get_ipa_representation(), "ai̯") # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = \ ['voiceless alveolar fricative', 'low front unrounded to close front unrounded diphthong'] ) self.assertEqual( ph_obj.get_ipa_representation(), "sai̯") # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = \ ["voiceless alveolar to voiceless palatoalveolar affricate"] ) self.assertEqual( ph_obj.get_ipa_representation(), "t͡ʃ") # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = ["voiced alveolar to voiced palatoalveolar affricate"] ) self.assertEqual( ph_obj.get_ipa_representation(), "d͡ʒ") # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = ["voiceless alveolar to voiceless alveolar affricate"] ) self.assertEqual( ph_obj.get_ipa_representation(), "t͡s") # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = ["open mid front unrounded to " \ "close back rounded diphthong"] ) self.assertEqual( ph_obj.get_ipa_representation(), "ɛu̯") # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ph_obj = PhoSegObject( soundsnames = ["extralong open mid front unrounded to " \ "close back rounded diphthong"] ) self.assertEqual( ph_obj.get_ipa_representation(), "ɛːu̯")
def test_get_cv_structure(self): """ TestPhoseg.test_get_cv_structure """ # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( phosegobj.get_cv_structure(), [] ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "a" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( phosegobj.get_cv_structure(), ["v",] ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "m" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( phosegobj.get_cv_structure(), ["c",] ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "mapi" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( phosegobj.get_cv_structure(), ["c", "v", "c", "v"] ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "ʰtːapi" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( phosegobj.get_cv_structure(), ["c", "v", "c", "v",] ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "ʰtːaːpi" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( phosegobj.get_cv_structure( chars=("c", "v") ), ["c", "v", "c", "v"] ) # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ipastring = "ʰtːaːpi" phosegobj = PhoSegObject( ipa = ipastring ) self.assertEqual( phosegobj.get_cv_structure( chars=("c", "v", "vː") ), ["c", "vː", "c","v"] )