Skip to content

Commit

Permalink
Merge pull request #8 from OneAdder/release_0_8_7
Browse files Browse the repository at this point in the history
Release 0 8 7
  • Loading branch information
OneAdder authored Aug 30, 2024
2 parents 5bac7b2 + 21cc6af commit ffc963f
Show file tree
Hide file tree
Showing 12 changed files with 26,981 additions and 24,624 deletions.
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@
<img src="https://img.shields.io/pypi/v/lingtypology.svg"/>
</td>
</tr>
<tr>
<td> Build Status </td>
<td>
<a href="https://travis-ci.org/OneAdder/lingtypology"/>
<img src="https://img.shields.io/travis/OneAdder/lingtypology.svg"/>
</td>
</tr>
<tr>
<td>Code Quality</td>
<td>
<a href="https://app.codacy.com/app/OneAdder/lingtypology?utm_source=github.com&utm_medium=referral&utm_content=OneAdder/lingtypology&utm_campaign=Badge_Grade_Dashboard"/>
<img src="https://api.codacy.com/project/badge/Grade/abe7b99539d141c4acbd3b485fd80959"/>
</td>
</tr>
<tr>
<td>License</td>
<td>
Expand All @@ -43,17 +29,15 @@ It uses the same phylosophy and provides similar functionality.

## Installation
The package is available in PyPI.
Therefore, you can install it by running:
Locally: `pip3 install lingtypology --user`
Globally (not recommended): `sudo pip3 install lingtypology`
Therefore, you can install it by running: pip install lingtypology`

## Usage
Lingtypology package contains `LingMap` class that allows to draw interactive maps, `glottolog` library that allows to interact with Glottolog data and `datasets` that allows to interact with different other linguistic databases.
For more informations consult [Lingtypology: Documentation](https://oneadder.github.io/lingtypology/).

## Glottolog
Lingtypology relies on data from the [Glottolog](https://glottolog.org/glottolog/language) database.
With each new version of `lingtypology` Glottolog data is updated. Now it is using Glottolog `3.4-41`.
With each new version of `lingtypology` Glottolog data is updated. Now it is using Glottolog `5.0`.
You can update data from Glottolog. To get the instruction on how to do it, consult the [tutorial](https://oneadder.github.io/lingtypology/glottolog#g_version).

## Citation
Expand Down
1 change: 0 additions & 1 deletion lingtypology/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import lingtypology.datasets
import lingtypology.glottolog

__version__ = '0.8.6'
__citation__ = \
'@misc{MichaelVoronov2669068,\n' \
' author = {Michael Voronov},\n' \
Expand Down
2 changes: 1 addition & 1 deletion lingtypology/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _get_wals_data(self, feature):
"""
wals_url = 'http://wals.info/feature/{}.tab'.format(feature)
try:
df_feature = pandas.read_csv(wals_url, delimiter='\t', skiprows=7)
df_feature = pandas.read_csv(wals_url, delimiter='\t', skiprows=5)
except urllib.error.HTTPError:
warnings.warn(
'(Wals) Warning: cannot read Wals feature ' + feature
Expand Down
24,549 changes: 0 additions & 24,549 deletions lingtypology/glottolog-languoids-v4.0-26-gb2138530b3.csv

This file was deleted.

26,929 changes: 26,929 additions & 0 deletions lingtypology/glottolog-languoids-v5.0.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": "http://www.w3.org/ns/csvw",
"dc:": "Harald Hammarstr\u00f6m, Robert Forkel & Martin Haspelmath. clld/glottolog: Glottolog database (Version v4.0-26-gb2138530b3) [Data set]. Zenodo. http://doi.org/10.5281/zenodo.596479",
"dc:version": "v4.0-26-gb2138530b3",
"dc:bibliographicCitation": "Harald Hammarstr\u00f6m & Robert Forkel & Martin Haspelmath & Sebastian Bank. glottolog/glottolog: Glottolog database (Version glottolog-master) [Data set]. Zenodo. https://doi.org/10.5281/zenodo.596479",
"dc:version": "glottolog-master",
"tables": [
{
"dc:conformsTo": "http://cldf.clld.org/v1.0/terms.rdf#LanguageTable",
Expand Down Expand Up @@ -31,8 +31,8 @@
{
"datatype": {
"base": "decimal",
"minimum": -90,
"maximum": 90
"minimum": "-90",
"maximum": "90"
},
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#latitude",
"required": false,
Expand All @@ -41,8 +41,8 @@
{
"datatype": {
"base": "decimal",
"minimum": -180,
"maximum": 180
"minimum": "-180",
"maximum": "180"
},
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#longitude",
"required": false,
Expand All @@ -55,7 +55,7 @@
},
"propertyUrl": "http://cldf.clld.org/v1.0/terms.rdf#glottocode",
"required": false,
"valueUrl": "http://glottolog.org/resource/languoid/id/{glottocode}",
"valueUrl": "http://glottolog.org/resource/languoid/id/{Glottocode}",
"name": "Glottocode"
},
{
Expand All @@ -67,6 +67,9 @@
"required": false,
"name": "ISO639P3code"
},
{
"name": "LL_Code"
},
{
"separator": "/",
"name": "Classification"
Expand Down Expand Up @@ -95,7 +98,7 @@
}
]
},
"url": "glottolog-languoids-v4.0-26-gb2138530b3.csv"
"url": "glottolog-languoids-glottolog-master.csv"
}
]
}
23 changes: 12 additions & 11 deletions lingtypology/glottolog.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,28 @@ def get_coordinates(language):
get_coordinates('Russian')
>>> (59.0, 50.0)
'''
latitude = glottolog[glottolog.Name == language].Latitude
longitude = glottolog[glottolog.Name == language].Longitude
if not list(latitude) or not list(longitude):
language_row = glottolog[glottolog.Name == language]
latitude_values = language_row['Latitude']
longitude_values = language_row['Longitude']
if not len(latitude_values) == 1 or not len(longitude_values) == 1:
global warnings
warnings.append(language)
else:
return (float(latitude), float(longitude))
return next(iter(latitude_values)), next(iter(longitude_values))

def get_coordinates_by_glot_id(glot_id):
'''
>>> get_coordinates_by_glot_id('russ1263')
(59.0, 50.0)
'''
latitude = glottolog[glottolog.ID == glot_id].Latitude
longitude = glottolog[glottolog.ID == glot_id].Longitude
try:
coordinates = (float(latitude), float(longitude))
except TypeError:
pass
language_row = glottolog[glottolog.ID == glot_id]
latitude_values = language_row['Latitude']
longitude_values = language_row['Longitude']
if not len(latitude_values) == 1 or not len(longitude_values) == 1:
global warnings
warnings.append(glot_id)
else:
return coordinates
return next(iter(latitude_values)), next(iter(longitude_values))

def get_glot_id(language):
'''
Expand Down
4 changes: 2 additions & 2 deletions lingtypology/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,8 @@ def _prepare_features(self, features, stroke=False, use_shapes=False):
colormap_colors = self.stroke_colormap_colors \
if stroke \
else self.colormap_colors
features = self._sort_all(features)

features = features if stroke else self._sort_all(features)
if numeric:
if not all(isinstance(f, int) or isinstance(f, float) for f in features):
try:
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
For more informations consult [Lingtypology: Documentation](https://oneadder.github.io/lingtypology/).
"""
from setuptools import setup
from lingtypology import __version__

setup(
name='lingtypology',
version=__version__,
version="0.8.7",
description='A tool for linguistic typology.',
long_description=__doc__,
long_description_content_type='text/markdown',
Expand Down
27 changes: 23 additions & 4 deletions tests/test_lingtypology.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from operator import itemgetter

import pandas
from lingtypology import *
Expand Down Expand Up @@ -128,6 +129,17 @@ def test_LingMap_merge():
m2 = LingMap('English')
merge(m1, m2).create_map()

def test_LingMap_stroke_features_after_rendered():
languages = ["Adyghe", "Kabardian", "Polish", "Russian", "Bulgarian"]
features = ["Agglutinative", "Agglutinative", "Inflected", "Inflected", "Analytic"]
stroke_features = ['Ergative', 'Ergative', 'Accusative', 'Accusative', 'Accusative']
m = lingtypology.LingMap(languages)
m.add_features(features)
m.add_stroke_features(stroke_features)
m.create_map()
features_after = list(map(itemgetter(0), m.all_attrs))
assert features_after == features

def test_LingMapError():
try:
m = lingtypology.LingMap('Russian')
Expand All @@ -143,7 +155,7 @@ def test_Glottolog():
isos = set()
coordinates = set()

affiliations0_ex = 'Indo-European, Balto-Slavic, Slavic, East Slavic'
affiliations0_ex = 'Indo-European, Classical Indo-European, Balto-Slavic, Slavic, East Slavic'
macroarea_ex = 'Eurasia'

languages.add(glottolog.get_by_iso('rus'))
Expand Down Expand Up @@ -172,9 +184,16 @@ def test_Glottolog():
affiliations0 == affiliations0_ex and \
macroarea == macroarea_ex
assert assertion

def test_wals():
datasets.Wals('1a', '20a', '3a').get_df(join_how='outer')

@pytest.mark.parametrize(
'tables',
[
('1a', '20a', '3a'),
('1a', '2a'),
],
)
def test_wals(tables):
datasets.Wals(*tables).get_df(join_how='outer')

def test_autotyp():
datasets.Autotyp('Gender', 'Agreement').get_df()
Expand Down
7 changes: 0 additions & 7 deletions tox.ini

This file was deleted.

0 comments on commit ffc963f

Please sign in to comment.