Created
February 8, 2016 22:32
-
-
Save dela3499/b5d519ddc7aa6a48d6dd to your computer and use it in GitHub Desktop.
Produce candidate pronunciation for an acronym. Take set of letters, perhaps a potential acronym, and try to expand it. Maybe just to have a new word to pronounce. Turn crps to carapace.
This file contains hidden or 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
import numpy as np | |
import toolz as tz | |
np.random.seed(1000) | |
# String -> String | |
def generate_word(word): | |
""" Given a word, return a new word with vowels interspersed between the letters. """ | |
vowels = list('aeiouy_') | |
letters = list(word) | |
additions = list(np.random.choice(vowels, size = len(letters) + 1, replace = True)) | |
return (''.join(list(tz.interleave([additions, letters])))).replace('_','') | |
[generate_word('crps') for _ in range(20)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't work very well. Would be better to actually break into phonemes and construct words from common phonemes, or to find words that seem to contain these phonemes. Could be made to work, I think. Perhaps NLTK has some tools that could assist in this.