def make_common_accent_ids(self) -> AccentsDict: all_accents: Set[str] = set() for ds in self.data: all_accents |= ds.accent_ids.get_all_accents() new_accent_ids = AccentsDict.init_from_accents_with_pad(all_accents) for ds in self.data: for entry in ds.data.items(): original_accents = ds.accent_ids.get_accents( entry.serialized_accent_ids) entry.serialized_accent_ids = new_accent_ids.get_serialized_ids( original_accents) ds.accent_ids = new_accent_ids return new_accent_ids
def test_init_from_accents_with_pad_ignores_existing_pad(self): res = AccentsDict.init_from_accents_with_pad({"b", "a", "xx"}, "xx") self.assertEqual("xx", res.get_accent(0)) self.assertEqual("a", res.get_accent(1)) self.assertEqual("b", res.get_accent(2))
def test_init_from_accents_with_pad_has_pad_at_idx_zero(self): res = AccentsDict.init_from_accents_with_pad({"b", "a"}, "xx") self.assertEqual("xx", res.get_accent(0)) self.assertEqual("a", res.get_accent(1)) self.assertEqual("b", res.get_accent(2))
def test_init_from_accents_with_pad_uses_pad_const(self): res = AccentsDict.init_from_accents_with_pad({"b", "a"}) self.assertEqual(PADDING_ACCENT, res.get_accent(0)) self.assertEqual("a", res.get_accent(1)) self.assertEqual("b", res.get_accent(2))