Skip to content

Commit

Permalink
revised the way that rhyming words are found. This should spend less …
Browse files Browse the repository at this point in the history
…time trying words that aren't rhymes at the end of lines.
  • Loading branch information
summerstay authored May 15, 2020
1 parent 3d505b1 commit d3148dd
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 113 deletions.
25 changes: 25 additions & 0 deletions make_rhyming_tokens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 20:55:21 2020
@author: Doug
"""

import pickle
from collections import defaultdict

rhyming_tokens = defaultdict(set)
syllable_tokens = [set() for y in range(10)]
for word in rhyme_dictionary:
rhyme_part = rhyme_dictionary[word]
rhyming_words = reverse_rhyme_dictionary[rhyme_part]
for rhyming_word in rhyming_words:
these_rhyming_tokens=tokenizer.encode(rhyming_word,add_prefix_space = True)
rhyming_tokens[word] = rhyming_tokens[word].union(set(these_rhyming_tokens))
word_tokens=tokenizer.encode(word,add_prefix_space = True)
syll_count = min(syllable_count_dictionary[word.upper()],9)
syllable_tokens[syll_count] = syllable_tokens[syll_count].union(word_tokens)

with open("rhyming_tokens.p","wb") as f:
pickle.dump(rhyming_tokens, f)
pickle.dump(syllable_tokens, f)
Binary file added rhyming_tokens.p
Binary file not shown.
Binary file added syllable_tokens.p
Binary file not shown.
Loading

0 comments on commit d3148dd

Please sign in to comment.