LingPy

lingpy.algorithm.misc.class2tokens

lingpy.algorithm.misc.class2tokens(tokens, classes, gap_char='-')

Turn aligned sound-class sequences into an aligned sequences of IPA tokens.

Parameters :

tokens : list

The list of tokens corresponding to the unaligned IPA string.

classes : string or list

The aligned class string.

gap_char : string

The character which indicates gaps in the aligned class string (defaults to “-”).

Returns :

alignment : list

A list of tokens with gaps at the positions where they occured in the alignment of the class string.

Examples

>>> from lingpy import *
>>> tokens = ipa2tokens('t͡sɔyɡə')
>>> aligned_sequence = 'CU-KE'
>>> print ', '.join(class2tokens(tokens,aligned_sequence))
t͡s, ɔy, -, ɡ, ə