Database APIs

APIs for different linguistic databases can be accessed with lingtypology.db_apis.

In [1]:
import lingtypology.db_apis

0. Table of Contents

1. Wals

2. Autotyp

3. AfBo

4. SAILS

1. Wals

It is possible to access Wals data (online) using lingtypology.db_apis.Wals

In [2]:
from lingtypology.db_apis import Wals

You can get the list of Wals pages by running:

Wals().features_list

You can get multiple Wals pages by passing their names into Wals. Method get_df returns the data in pandas.DataFrame type. You can also get it as dict using get_json method.

In [3]:
wals_page = Wals('1a', '2a').get_df()
wals_page.head()
Citation for feature 1A:
Ian Maddieson. 2013. Consonant Inventories.
In: Dryer, Matthew S. & Haspelmath, Martin (eds.)
The World Atlas of Language Structures Online.
Leipzig: Max Planck Institute for Evolutionary Anthropology.
(Available online at http://wals.info/chapter/1, Accessed on 2019-05-08.)

Citation for feature 2A:
Ian Maddieson. 2013. Vowel Quality Inventories.
In: Dryer, Matthew S. & Haspelmath, Martin (eds.)
The World Atlas of Language Structures Online.
Leipzig: Max Planck Institute for Evolutionary Anthropology.
(Available online at http://wals.info/chapter/2, Accessed on 2019-05-08.)

Out[3]:
wals code language genus family area coordinates _1A _2A
0 kiw Kiwai (Southern) Kiwaian Kiwaian Phonology (-8.0, 143.5) Small Average (5-6)
1 xoo !Xóõ Tu Tu Phonology (-24.0, 21.5) Large Average (5-6)
2 ani //Ani Khoe-Kwadi Khoe-Kwadi Phonology (-18.9166666667, 21.9166666667) Large Average (5-6)
3 abi Abipón South Guaicuruan Guaicuruan Phonology (-29.0, -61.0) Moderately small Average (5-6)
4 abk Abkhaz Northwest Caucasian Northwest Caucasian Phonology (43.0833333333, 41.0) Large Small (2-4)

Finally, we can now easily draw a map out of the data from the Wals page "1A" (size of consonant inventory).

In [4]:
m = lingtypology.LingMap(wals_page.language)
m.add_custom_coordinates(wals_page.coordinates)
m.add_features(wals_page._1A)
m.legend_title = 'Consonant Inventory'
m._create_map()
Out[4]:

2. Autotyp

It is possible to access Autotyp data (online) using lingtypology.db_apis.

In [5]:
from lingtypology.db_apis import Autotyp

To get the list of Autotyp features run:

Autotyp().features_list

Unlike in Wals, each new tablename passed into Autotyp gives several additional columns:

In [6]:
Autotyp_table = Autotyp('Gender', 'Agreement').get_df()
Autotyp_table.head()
Bickel, Balthasar, Johanna Nichols, Taras Zakharko,
Alena Witzlack-Makarevich, Kristine Hildebrandt, Michael Rießler,
Lennart Bierkandt, Fernando Zúñiga & John B. Lowe.
2017. The AUTOTYP typological databases.
Version 0.1.0 https://github.com/autotyp/autotyp-data/tree/0.1.0
(get_by_glot_id) Warning: language by ngiy1239 not found
(get_by_glot_id) Warning: language by east2283 not found
Out[6]:
Language LID Gender.n Gender.binned4 Gender.Presence VPolyagreement.Presence.v2 VPolyagreement.Presence.v1
0 Godoberi 1531 3 3 genders True False False
1 Bininj Kun-Wok 655 4 4 genders True True True
2 Luvale 553 10 more than 4 genders True True False
3 North-Central Dargwa 2949 3 3 genders True True True
4 Gaagudju 82 4 4 genders True True True

Now we can draw a map out of gender data from multiple languages.

In [7]:
m = lingtypology.LingMap(Autotyp_table.Language)
m.add_features(Autotyp_table['Gender.binned4'])
m.legend_title = 'Genders'
m._create_map()
Out[7]:

3. AfBo

In [8]:
from lingtypology.db_apis import AfBo

To get the list of features from AfBo run:
AfBo().features_list

To get the AfBo data as dict, you can use get_json method. To get data as pandas.DataFrame you can run:

In [9]:
c = AfBo('comparative').get_df()
c.head()
Seifart, Frank. 2013.
AfBo: A world-wide survey of affix borrowing.
Leipzig: Max Planck Institute for Evolutionary Anthropology.
(Available online at http://afbo.info, Accessed on 2019-05-09.)
Out[9]:
Recipient_name Donor_name reliability comparative
0 Resígaro Bora high 0
1 Gurindji Kriol Gurindji high 0
2 Copper Island Aleut Russian high 0
3 Sakha Mongolian high 0
4 Kalderash Romani Romanian high 0
In [10]:
m = lingtypology.LingMap(c.Recipient_name)
m.add_features(c['comparative'])
m._create_map()
#adj['possessor indexing']
Out[10]:

4. SAILS

In [11]:
from lingtypology.db_apis import Sails

Get list of features:
Sails().features_list To get a pandas.DataFrame of features and descriptions:

In [12]:
Sails().features_descriptions.head()
Out[12]:
Feature Description
0 ICU17 Is plurality in independent pronouns expressed...
1 ICU16 Is plurality in independent pronouns expressed...
2 ICU15 Is plurality in independent pronouns expressed...
3 ICU14 Is an associative or collective plural disting...
4 ICU13 Are nouns denoting inanimates marked for plural?

Get description for particular features:

In [13]:
Sails().feature_descriptions('ICU10', 'ICU11')
Out[13]:
Feature Description
0 ICU10 Is nominal plural marking obligatory?
1 ICU11 Are nouns denoting humans marked for plural?

To get the SAILS data as dict, you can use get_json method. To get data as pandas.DataFrame you can run:

In [14]:
sails = Sails('ICU10', 'ICU11')
df = sails.get_df()
df.head()
You probably should cite it, but I don't understand how. Please, consult https://sails.clld.org/
Out[14]:
Language Coordinates ICU10 ICU10_desc ICU11 ICU11_desc
0 Tol (14.66859, -87.03719) 0 No 1 Yes
1 San Blas Kuna (9.15686, -78.3075) 0 No 1 Yes
2 Wayuu (10.22515, -71.81012) 0 No 1 Yes
3 Northern Emberá (7.127610000000001, -77.57396) 0 No 1 Yes
4 Páez (2.61516, -76.31254) 0 No 1 Yes

Map example:

In [15]:
m = lingtypology.LingMap(df.Language)
m.add_features(df.ICU11_desc)
m.legend_title = sails.feature_descriptions('ICU11').Description.at[0]
m.start_location = (9, -79)
m.start_zoom = 5
m._create_map()
Out[15]: