def all_allophone_variations(self, phon, states=None, all_boundary_variations=False): """ :param str phon: :param None|list[int] states: which states to yield for this phone :param bool all_boundary_variations: :return: yields AllophoneState's :rtype: list[AllophoneState] """ if states is None: states = range(self.num_states_for_phone(phon)) if all_boundary_variations: boundary_variations = [0, 1, 2, 3] else: boundary_variations = [0] for left_ctx in self._iter_possible_ctx(phon, -1): for right_ctx in self._iter_possible_ctx(phon, 1): for state in states: for boundary in boundary_variations: a = AllophoneState() a.id = phon a.context_history = left_ctx a.context_future = right_ctx a.state = state a.boundary = boundary if not all_boundary_variations: if not left_ctx: a.mark_initial() if not right_ctx: a.mark_final() yield a
def _allos_add_states(self, allos): for _a in allos: if _a.id == self.si_phone: yield _a else: # non-silence for state in range(self.allo_num_states): a = AllophoneState() a.id = _a.id a.context_history = _a.context_history a.context_future = _a.context_future a.boundary = _a.boundary a.state = state yield a
def all_allophone_variations(self, phon, states=None): if states is None: states = range(self._num_states(phon)) for left_ctx in self._iter_possible_ctx(phon, -1): for right_ctx in self._iter_possible_ctx(phon, 1): for state in states: a = AllophoneState() a.id = phon a.context_history = left_ctx a.context_future = right_ctx a.state = state a.boundary = 0 if not left_ctx: a.boundary |= 1 # initial if not right_ctx: a.boundary |= 2 # final yield a