-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revised the way that rhyming words are found. This should spend less …
…time trying words that aren't rhymes at the end of lines.
- Loading branch information
1 parent
3d505b1
commit d3148dd
Showing
4 changed files
with
126 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 not shown.
Binary file not shown.
Oops, something went wrong.