def rhyme_style_jiao(self, count, predict, last_word_a, last_word_b, used_words): if count % 2 == 0: # A韵 rhyme_words, rhyme_words_index = get_next_sentence_rhyme_word( last_word=last_word_a, rhyme_mode=self.rhyme_mode, result_rhyme_word_len=2, prob=predict[-1], int_to_word=self.model.data.int_to_word, word_to_int=self.model.data.word_to_int, used_words=used_words) used_words.append(rhyme_words[0]) first_word = rhyme_words_index[0] else: # B韵 rhyme_words, rhyme_words_index = get_next_sentence_rhyme_word( last_word=last_word_b, rhyme_mode=self.rhyme_mode, result_rhyme_word_len=2, prob=predict[-1], int_to_word=self.model.data.int_to_word, word_to_int=self.model.data.word_to_int, used_words=used_words) used_words.append(rhyme_words[0]) first_word = rhyme_words_index[0] count += 1 return count, first_word, used_words
def rhyme_style_gehang(self, count, predict, last_word_a, used_words): if count % 2 == 0: # 不押韵 first_word = get_sort_word_by_prob(self.model.data.int_to_word, predict[-1]) used_words.append(first_word) first_word = self.model.data.word_to_int[first_word] else: # 押韵 rhyme_words, rhyme_words_index = get_next_sentence_rhyme_word( last_word=last_word_a, rhyme_mode=self.rhyme_mode, result_rhyme_word_len=2, prob=predict[-1], int_to_word=self.model.data.int_to_word, word_to_int=self.model.data.word_to_int, used_words=used_words) used_words.append(rhyme_words[0]) first_word = rhyme_words_index[0] count += 1 return count, first_word, used_words
def rhyme_style_pai(self, count, predict, last_word, used_words): if count % self.rhyme_change_gap != 0: # 不换韵 count += 1 rhyme_words, rhyme_words_index = get_next_sentence_rhyme_word( last_word=last_word, rhyme_mode=self.rhyme_mode, result_rhyme_word_len=2, prob=predict[-1], int_to_word=self.model.data.int_to_word, word_to_int=self.model.data.word_to_int, used_words=used_words) used_words.append(rhyme_words[0]) first_word = rhyme_words_index[0] else: # 换韵 count = 1 first_word = get_sort_word_by_prob(self.model.data.int_to_word, predict[-1]) used_words.append(first_word) last_word = first_word first_word = self.model.data.word_to_int[first_word] return count, first_word, last_word, used_words