LingPy

This documentation is for version 2.0.dev, which is not released yet.

lingpy.align.sca.Alignments.get_list

Alignments.get_list(row='', col='', entry='', flat=False, **keywords)

Function returns lists of rows and columns specified by their name.

Parameters :

row: string (default = ‘’) :

The row name whose entries are selected from the data.

col : string (default = ‘’)

The column name whose entries are selected from the data.

entry: string (default = ‘’) :

The entry-type which is selected from the data.

flat : bool (default = False)

Specify whether the returned list should be one- or two-dimensional, or whether it should contain gaps or not.

Returns :

data : list

A list representing the selected part of the data.

See also

Wordlist.get_list, Wordlist.add_entries

Notes

The ‘col’ and ‘row’ keywords in the function are all aliased according to the description in the wordlist.rc file. Thus, instead of using these attributes, the aliases can also be taken. For selecting a language, one may type something like:

>>> Wordlist.get_list(language='LANGUAGE')

and for the selection of a concept, one may type something like:

>>> Wordlist.get_list(concept='CONCEPT')    

See the examples below for details.

Examples

Load the harry_potter.csv file:

>>> wl = Wordlist('harry_potter.csv')

Select all IPA-entries for the language “German”:

>>> wl.get_list(language='German',entry='ipa'
['bain', 'hant', 'haralt']

Note that this function returns 0 for missing values (concepts that don’t have a word in the given language). If one wants to avoid this, the ‘flat’ keyword should be set to c{True}.

Select all words (orthographical representation) for the concept “Harry”:

>>> wl.get_list(concept="Harry",entry="words")
[['hæri', 'haralt', 'gari', 'gari']]            

Note that the values of the list that is returned are always two-dimensional lists, since it is possible that the original file contains synonyms (multiple words corresponding to the same concept). If one wants to have a flat representation of the entries, the ‘flat’ keyword should be set to c{True}:

>>> wl.get_list(concept="Harry",entry="words",flat=True)
['hæri', 'haralt', 'gari', 'gari']