def test_epsilon_emission(self): self.initialise_segment_table("plural_english_segment_table.txt") from fst import EPSILON hmm = HMM({'q0': ['q1'], 'q1': (['q2'], ['dog', 'kat']), 'q2': (['qf'], ['z', EPSILON]) }) self.write_to_dot_to_file(hmm, 'epsilon_hmm') hmm_transducer = hmm.get_transducer() self.write_to_dot_to_file(hmm_transducer, 'epsilon_hmm_transducer') grammar = Grammar(hmm, None) word_1 = 'dog' word_2 = 'dogz' print(hmm) hypothesis = Hypothesis(grammar, [word_1, word_2]) encoding_length = hypothesis.get_data_encoding_length_by_grammar() assert encoding_length == 4.0 print(hmm.add_epsilon_emission_to_state()) print(hmm.add_epsilon_emission_to_state()) print(hmm.add_epsilon_emission_to_state()) print(hmm.remove_epsilon_emission_from_state()) print(hmm.remove_epsilon_emission_from_state()) print(hmm.add_epsilon_emission_to_state()) self.write_to_dot_to_file(hmm, 'epsilon_hmm_after_mutation')