Approximate country and language name matching.
Project description
# Globetrotter
Approximate country and language name matching for `pycountry`, making it an even better reference for messy data.
## Motivation
```
>>> import pycountry
>>> pycountry.countries.get(name='Vietnam')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/you/Library/Python/2.7/lib/python/site-packages/pycountry/db.py", line 85, in get
return self.indices[field][value]
KeyError: 'Vietnam'
>>>
```
'Nuff said.
## Usage
Find a country through the `find_country()` method, giving it an approximate string name. It returns a `Country` object with ISO metadata about the match.
```
>>> import globetrotter
g>>> globetrotter.find_country('Vietnam')
<pycountry.db.Country object at 0x1038eed90>
>>> globetrotter.find_country('Vietnam').name
u'Viet Nam'
```
Find a language through the `find_language()` method in a similar way. It returns a `Language` object.
```
>>> import globetrotter
>>> globetrotter.find_language('Spanish')
<pycountry.db.Language object at 0x103a444d0>
>>> globetrotter.find_language('Spanish').name
u'Spanish; Castilian'
```
Approximate country and language name matching for `pycountry`, making it an even better reference for messy data.
## Motivation
```
>>> import pycountry
>>> pycountry.countries.get(name='Vietnam')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/you/Library/Python/2.7/lib/python/site-packages/pycountry/db.py", line 85, in get
return self.indices[field][value]
KeyError: 'Vietnam'
>>>
```
'Nuff said.
## Usage
Find a country through the `find_country()` method, giving it an approximate string name. It returns a `Country` object with ISO metadata about the match.
```
>>> import globetrotter
g>>> globetrotter.find_country('Vietnam')
<pycountry.db.Country object at 0x1038eed90>
>>> globetrotter.find_country('Vietnam').name
u'Viet Nam'
```
Find a language through the `find_language()` method in a similar way. It returns a `Language` object.
```
>>> import globetrotter
>>> globetrotter.find_language('Spanish')
<pycountry.db.Language object at 0x103a444d0>
>>> globetrotter.find_language('Spanish').name
u'Spanish; Castilian'
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
globetrotter-0.1.0.tar.gz
(1.8 kB
view details)
File details
Details for the file globetrotter-0.1.0.tar.gz
.
File metadata
- Download URL: globetrotter-0.1.0.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d92d4af7677b6212a4202e877e7e1b8aeeeffa1e5c015b00da1f8f0e22c9b6c |
|
MD5 | 1e2ab42d5505c619d6201009554bbe12 |
|
BLAKE2b-256 | 16da7520bd679048611b43d5c08568e1cc00e91cde020c593a9ec893fbe8785b |