LingPy

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

lingpy.align.sca.Alignments.get_dict

Alignments.get_dict(col='', row='', entry='', **keywords)

Function returns dictionaries of the cells matched by the indices.

Parameters :

col : string (default=’‘)

The column index evaluated by the method. It should contain one of the values in the row of the Wordlist instance, usually a taxon (language) name.

row : string (default=’‘)

The row index evaluated by the method. It should contain one of the values in the row of the Wordlist instance, usually a taxon (language) name.

entry : string (default = ‘’)

The index for the entry evaluated by the method. It can be used to specify the datatype of the rows or columns selected. As a default, the indices of the entries are returned.

Returns :

entries : dict

A dictionary of keys and values specifying the selected part of the data. Typically, this can be a dictionary of a given language with keys for the concept and values as specified in the “entry” keyword.

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_dict(language='LANGUAGE')

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

>>> Wordlist.get_dict(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_dict(language='German',entry='ipa')
{'Harry': ['haralt'], 'hand': ['hant'], 'leg': ['bain']}

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

>>> wl.get_dict(concept="Harry",entry="words")
{'English': ['hæri'], 'German': ['haralt'], 'Russian': ['gari'], 'Ukrainian': ['gari']}

Note that the values of the dictionary that is returned are always lists, since it is possible that the original file contains synonyms (multiple words corresponding to the same concept).