Skip to content

Instantly share code, notes, and snippets.

@dela3499
Created February 8, 2016 22:32
Show Gist options
  • Save dela3499/b5d519ddc7aa6a48d6dd to your computer and use it in GitHub Desktop.
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.
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)]
@dela3499
Copy link
Author

dela3499 commented Feb 8, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment