Phonesse

Elements Methods

phonomialsBase.vowels()[source]

Returns a list oll English vowels (APRABET)

Returns:list of strings (vowels)
>>> phonomial.vowels()
['IY','IH','EY','EH','AH','ER','AY','UW','UH','OW','AO','AE','OY','AW','AA']
phonomialsBase.consonants()[source]

Returns a list oll English consonants (APRABET)

Returns:list of strings (consonants)
>>> phonomial.consonants()
['B','CH','D','DH','F','G','HH','JH','K','L','M','N','NG','P','R','S','SH','T','TH','W','V','Y','Z','ZH']
phonomialsBase.arpabet_2_ipa_dict()[source]

Returns a dictionary where keys are ARPABET and values are IPA symbols

Returns:dict
>>> arpabet_2_ipa_dict()
        {'IY': 'i',
         'IH': 'I',
         'EY': 'eI',
         'EH': 'ɛ',
         'AH': 'ʌ',
         'ER': 'ɝ',
         'AY': 'aI',
         'UW': 'u',
         'UH': 'ʊ',
         'OW': 'oʊ',
         'AO': 'ɔ',
         'AE': 'æ',
         'OY': 'ɔI',
         'AW': 'aʊ',
         'AA': 'ɑ',
         'B': 'b',
         'CH': 'tʃ',
         'D': 'd',
         'DH': 'ð',
         'F': 'f',
         'G': 'ɡ',
         'HH': 'h',
         'JH': 'dʒ',
         'K': 'k',
         'L': 'l',
         'M': 'm',
         'N': 'n',
         'NG': 'ŋ',
         'P': 'p',
         'R': 'ɹ',
         'S': 's',
         'SH': 'ʃ',
         'T': 't',
         'TH': 'θ',
         'V': 'v',
         'W': 'w',
         'Y': 'j',
         'Z': 'z',
         'ZH': 'ʒ'}
phonomialsBase.consonants_naturalclasses_dict()[source]

Returns a dictionary where keys are ARPABET and values are lists of natural classes associated with each segment

Returns:dict
>>>
cons_naturalclasses['B'] =  ['voiced','bilabial','stop']
cons_naturalclasses['CH'] = ['voiceless','postalveolar','sibilant','affricate']
cons_naturalclasses['D'] = ['voiced','alveolar','dental','postalveolar','stop']
cons_naturalclasses['DH'] = ['voiced','dental','fricative']
cons_naturalclasses['F'] = ['voiceless','llabiodental','fricative']
cons_naturalclasses['G'] = ['voiced','velar','stop']
cons_naturalclasses['HH'] = ['voiceless','glottal','fricative']
cons_naturalclasses['JH'] = ['voiced','postalveolar','sibilant','affricate']
cons_naturalclasses['K'] = ['voiceless','velar','stop']
cons_naturalclasses['L'] = ['voiced','alveolar','lateral','approximant']
cons_naturalclasses['M'] = ['voiced','bilabial','nasal']
cons_naturalclasses['N'] = ['voiced','alveolar','nasal']
cons_naturalclasses['NG'] = ['voiced','velar','nasal']
cons_naturalclasses['P'] = ['voiceless','bilabial','stop']
cons_naturalclasses['R'] = ['voiced','alveolar','approximant']
cons_naturalclasses['S'] = ['voiceless','alveolar','fricative']
cons_naturalclasses['SH'] = ['voiceless','postalveolar','fricative']
cons_naturalclasses['T'] = ['voiceless','alveolar','posstalveolar','dental','stop']
cons_naturalclasses['TH'] = ['voiceless','dental','non-sibilant','fricative']
cons_naturalclasses['V'] = ['voiced','labiodental','fricative']
cons_naturalclasses['W'] = ['voiced','labial-velar','approximant']
cons_naturalclasses['Y'] = ['voiced','palatal','approximant']
cons_naturalclasses['Z'] = ['voiced','alveolar','fricative']
cons_naturalclasses['ZH'] = ['voiced','postalveolar','fricative']
phonomialsBase.vowels_naturalclasses_dict()[source]

Returns a dictionary where keys are ARPABET and values are lists of natural classes associated with each segment

Returns:dict
>>>
vowels_naturalclasses['IY'] = ['high','front','unrounded']
vowels_naturalclasses['IH'] = ['near-high','front','unrounded']
vowels_naturalclasses['EY'] = ['mid','central','near-high','front','unrounded','diphthong'] # dipthong
vowels_naturalclasses['EH'] = ['low-mid','front','unrounded']
vowels_naturalclasses['AH'] = ['near-low','central']
vowels_naturalclasses['ER'] = ['rhotic']
vowels_naturalclasses['AY'] = ['low','front','unrounded','near-high','diphthong'] # dipthong
vowels_naturalclasses['UW'] = ['high','back','rounded']
vowels_naturalclasses['UH'] = ['near-high','back','rounded']
vowels_naturalclasses['OW'] = ['high-mid','near-high','back','rounded','diphthong'] # dipthong
vowels_naturalclasses['AO'] = ['low-mid','back','rounded']
vowels_naturalclasses['AE'] = ['near-low','front','unrounded']
vowels_naturalclasses['OY'] = ['low-mid','back','rounded','near-high','front','unrounded','diphthong'] # dipthong
vowels_naturalclasses['AW'] = ['low','front','unrounded','near-high','back','rounded','diphthong'] # dipthong
vowels_naturalclasses['AA'] = ['low','central','unrounded']  y, w, l, r, m, n, and ng
phonomialsBase.ARPABET_2_naturalclasses(segment)[source]

Takes an ARPABET segment and returns the list of associated natural classes (includes both consonant and vowel items)

Parameters:segment – an ARPABET segment (string)
Returns:list of strings (natural classes)
>>> ARPABET_2_naturalclasses('IY')
['high','front','unrounded']

Plotting Methods

phonomialsBase.show_APRABET_examples()[source]

Basic Tables of Information about the sound segements in this package

Returns:Two tables, vowel and consonant examples.
phonomialsBase.show_vowel_colors(mode='plot')[source]

Plots the colors associated with vowels, optionally returns the dictionary of associations

Returns:Plotly plot
>>> show_vowel_colors(mode='dict')
        { 'XX':'rgb(255,255,255)',
        'IY':'rgb(240, 219, 116)',
        'IH':'rgb(182, 201, 103)',
        'EY':'rgb(165, 196, 125)',
        'EH':'rgb(146,190,152)',
        'AH':'rgb(127, 186, 178)',
        'ER':'rgb(103, 152, 173)',
        'AY':'rgb(84,120,165)',
        'UW':'rgb(67,90,158)',
        'UH':'rgb(79,78,137)',
        'OW':'rgb(86,62,117)',
        'AO':'rgb(91,64,100)',
        'AE':'rgb(43, 29, 67)',
        'OY':'rgb(32, 22, 49)',
        'AW':'rgb(21, 13, 32)',
        'AA':'rgb(0, 0, 0)'}
phonomialsBase.plot_as_grid(user_input, alignment='right', mode='vowels', delimiter='lines')[source]

This function plots color-coded vowel and stress segments in a grid configuration. It requires 1 param, either a string of orthographic text or a list of phonomial objects. There are also 3 other parameters, alignment, mode, and delimiter. :param user_input: (str) or [phonomial1,phonomial2,…] :param alignment: alignment

right: right-aligns left: left-aligns
Parameters:
  • mode – mode vowels: vowels stress: stress
  • delimiter – ‘lines’ or ‘sentences’
Returns:

Plotly Plot

phonomialsBase.plot_as_MIDI(user_input)[source]

This function plots color-coded vowel segments in a MIDI configuration. It requires 1 param, either a string of orthographic text or a single phonomial object.

Parameters:user_input – str or phonomial
Returns:Plotly plot
phonomialsBase.plot_phrase_set_summary(ps, take_n_columns, alignment)[source]

This function plots color-coded vowel segments in a MIDI configuration. It requires 1 param, either a string of orthographic text or a single phonomial object. If you pass it text is will convert it into a single phonomials.

Parameters:user_input – str or phonomial
Returns:Plotly plot
phonomialsBase.search_widget(syllables=1)[source]

Returns an interactive widget that allow building X syllables sound patterns and finding word matches. Specify X with the syllables parameter.

Parameters:syllables – int
Returns:pywidget

Support Methods

phonomialsBase.flatten(list_of_lists)[source]

Flattens a list of lists into a list

Parameters:param1 – list of lists
Returns:list
>>> phonomial.flatten([[1,2],[3,4]])
[1, 2, 3, 4]
phonomialsBase.n_grams(items, n_orders=2)[source]

Take a number of n-gram orders and a list of items, and returns list of n dictionaries. Each dictionary will contain the freequency counts for each size n-gram up to order n

Parameters:
  • items – list of items e.g. [‘A’,’A’,’B’,’C’,’D’,’E’,’E’,’F’,’G’,’H’]
  • n_orders – int (should not be longer than numbers of items)
Returns:

list of dictionaries

Raises:

keyError – raises an exception

This has a bug: it doesn’t seem to to including the very last element in any count

>>> phonesse.n_grams(3,['A','A','B','A','C','A','A','A','B','A','C'])[1]
[Counter({('A',): 7, ('B',): 2, ('C',): 1}),
Counter({('A', 'A'): 3,
                ('A', 'B'): 2,
                ('B', 'A'): 2,
                ('A', 'C'): 1,
                ('C', 'A'): 1}),
Counter({('A', 'A', 'B'): 2,
                ('A', 'B', 'A'): 2,
                ('B', 'A', 'C'): 1,
                ('A', 'C', 'A'): 1,
                ('C', 'A', 'A'): 1,
                ('A', 'A', 'A'): 1})]

Classes

class phonomialsBase.data(syll_length)[source]
static get_sample(sample='none')[source]

Flatten a 2D list into a 1D list - Use recursion on more than 2D lists if needed.

Parameters:param1 – phonomial
Returns:int of block or syllable count
Raises:keyError – raises an exception
>>> phonomial.flatten([[1,2],[3,4]])
[1, 2, 3, 4]
class phonomialsBase.phonomial(syll_length)[source]

A phonomial a simple class used to encode ARPABET representation in a form more conducive to modular coding than the simple string repressentation.

Parameters:param1 – phonomial
Returns:int of block or syllable count
Raises:keyError – raises an exception
>>> type(phonomial(1))
<type 'instance'>
classmethod from_string(ortho, altPronSave='no', split='none', ignore_missing=False, replace_missing=True, save_missing_to=False)[source]

Takes a string of text and returns a phonomial can return multiple phonomials by specifing a delimiter

Parameters:
  • ortho – str (orthographic text)
  • altPronSave – coming soon
  • split – str (‘lines’,’sents’)
  • ignore_missing – bool (if true, orthographic text will show up with returned sounds where sounds are not available)
  • replace_missing – bool (If true, uses neural network to predict pron. of unknown word)
  • save_missing_to – bool coming soon
Returns:

one or more phonomial objects

>>> type(phonomial.from_string("this"))
<type 'instance'>
get_cons(mode='blocks', flat='no', removeDelims='no', placeholder='no')[source]

Extract Consonants from a phonomial

Note that we can either run this func live if we need it, or we can run in in a loop, adding it as an attr to each phonomial

Parameters:param1 – phonomial
Returns:int of block or syllable count
Raises:keyError – raises an exception
get_vowels(mode='blocks', stress=False)[source]

Extract vowels from a phonomial

iterate across only vowels blocks in a phonomial

Parameters:param1 – phonomial
Returns:int of block or syllable count
Raises:keyError – raises an exception
static join(ps, delim='\n')[source]
Parameters:param1 – List of Phonomial objects
Returns:single Phonomial object
Raises:keyError – raises an exception
phonomialsBase.set_element(p, block_location='', element='')[source]

Take a phonomial, a block location to populate, and an element to put in the location.

Parameters:
  • p – phonomial
  • block_location – str (e.g. ‘C1’, ‘C2’, ‘V1’, ‘V2’, etc…)
  • element – ARPABET str (C positions only take consonants, V positions only take vowels) Block counts start at 1, left to right.
Returns:

The input phonomial updated with new element in block location