def test_get_last_words(self): WordsData(self.WORDS) word_tuple = ( Words( { "word": "古池", "vowel": "ウウイエ", "length": 4, "part": "名詞" } ), Words( { "word": "蛙", "vowel": "アエウ", "length": 3, "part": "名詞" } ), Words( { "word": "あ", "vowel": "ア", "length": 1, "part": "名詞" } ) ) pt = PhraseTree(word_tuple) next_word_tuple = ( Words( { "word": "蛙", "vowel": "アエウ", "length": 3, "part": "名詞" } ), Words( { "word": "あ", "vowel": "ア", "length": 1, "part": "名詞" } ), Words( { "word": "い", "vowel": "イ", "length": 1, "part": "名詞" } ) ) next_pt = PhraseTree(next_word_tuple, parent=pt) pt.next_tree = next_pt self.assertEqual( PhraseTree.get_last_words(pt), next_word_tuple )
def test_get_text_vowel(self): WordsData(self.WORDS) word_tuple = ( Words( { "word": "古池", "vowel": "ウウイエ", "length": 4, "part": "名詞" } ), Words( { "word": "蛙", "vowel": "アエウ", "length": 3, "part": "名詞" } ), Words( { "word": "あ", "vowel": "ア", "length": 1, "part": "名詞" } ) ) root = PhraseTree.define_root(possible_next_words=list(self.SUCCESS_CHAINS.keys())) second_tree = PhraseTree(current_words=word_tuple, parent=root) root.next_tree = second_tree self.assertEqual( root.get_text_vowel(second_tree), 'ウウイエアエウア' ) next_word_tuple = ( Words( { "word": "蛙", "vowel": "アエウ", "length": 3, "part": "名詞" } ), Words( { "word": "あ", "vowel": "ア", "length": 1, "part": "名詞" } ), Words( { "word": "いい", "vowel": "イイ", "length": 2, "part": "名詞" } ) ) third_tree = PhraseTree(current_words=next_word_tuple, possible_next_words=list(self.SUCCESS_CHAINS.keys()), parent=second_tree) second_tree.next_tree = third_tree self.assertEqual( root.get_text_vowel(third_tree), 'ウウイエアエウアイイ' )