Lingtypology

- Main Page
- Maps
- DB APIs

# Glottolog¶

You can access `Glottolog` data using `lingtypology.glottolog`

In [1]:

    from lingtypology import glottolog

## 0. Table of Contents¶

### 1. Glottolog Usage¶

### 2. Glottolog Version¶

## 1. Usage ¶

You can use a number of functions to work with Glottolog data.

Get genealogy information:

In [2]:

    glottolog.get_affiliations(('Russian', 'English'))

Out[2]:

    ['Indo-European, Balto-Slavic, Slavic, East Slavic',
     'Indo-European, Germanic, Northwest Germanic, West Germanic, North Sea Germanic, Anglo-Frisian, Anglic, Later Anglic, Middle-Modern English, Macro-English']

Get coordinates of a language:

In [3]:

    glottolog.get_coordinates('Russian')

Out[3]:

    (59.0, 50.0)

Get the Glottolog ID (aka Glottocode):

In [4]:

    glottolog.get_glot_id('Russian')

Out[4]:

    'russ1263'

Get coordinates by Glottocode:

In [5]:

    glottolog.get_coordinates_by_glot_id('russ1263')

Out[5]:

    (59.0, 50.0)

Get the macroarea:

In [6]:

    glottolog.get_macro_area('Russian')

Out[6]:

    'Eurasia'

Get the ISO code:

In [7]:

    glottolog.get_iso('Russian')

Out[7]:

    'rus'

Get language by ISO code:

In [8]:

    glottolog.get_by_iso('rus')

Out[8]:

    'Russian'

Get language by Glottocode:

In [9]:

    glottolog.get_by_glot_id('russ1263')

Out[9]:

    'Russian'

Get Glottocode by ISO:

In [10]:

    glottolog.get_glot_id_by_iso('rus')

Out[10]:

    'russ1263'

Get ISO by Glottocode:

In [11]:

    glottolog.get_iso_by_glot_id('russ1263')

Out[11]:

    'rus'

## 2. Versions ¶

Each new release of `lingtypology` is shipped with the latest version of the Glottolog data. The information about the version of Glottolog can be retrieved using:

In [12]:

    from lingtypology import glottolog
    #Yet, I cannot guarantee that this tutorial is updated with each release.
    #If you want to get your version, run this code on your machine.
    glottolog.version

Out[12]:

    'v3.4-16-g44ed528cc7'

Nevertheless, if you want to get the newest release and do not wish to wait for the next version of `lingtypology`, you can download the version you wish locally by following these steps:

1) Download `glottolog` from here.

2) If you downloaded it as an archive, unpack it.

3) In your home directory make a folder and call it `.lingtypology_data` (with `.` in the beginning).

4) Move `glottolog` into `.lingtypology_data`.

5) Run the following command:
`glottolog --repos=glottolog languoids`

6) It will generate two small files (`csv` and `json`). Now you can delete everything except for these files from the directory.