Introduction¶
This library offers an implementation of the
skosprovider.providers.VocabularyProvider
interface based on the
Getty Vocabularies. It reduces the complex
vocabularies like AAT and TGN to a basic SKOS version
of them.
Supported Getty thesauri:
- The Art & Architecture Thesaurus (AAT) by use of the
skosprovider_getty.providers.AATProvider
. - The Getty Thesaurus of Geographic Names (TGN) by use of the
skosprovider_getty.providers.TGNProvider
. - The Union List of Artist Names (ULAN) by use of the
skosprovider_getty.providers.ULANProvider
.
Installation¶
To be able to use this library you need to have a modern version of Python installed. Currently we’re supporting versions 2.7, 3.3 and 3.4 of Python.
This easiest way to install this library is through pip or easy install:
$ pip install skosprovider_getty
This will download and install skosprovider_getty
and a few libraries it
depends on.
Using the providers¶
Using AATProvider¶
The AATProvider
is a provider for
the AAT. It’s use is identical to all other SKOSProviders.
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
This script demonstrates using the AATProvider to get the concept of
Churches.
'''
from skosprovider_getty.providers import AATProvider
aat = AATProvider(metadata={'id': 'AAT'})
churches = aat.get_by_id(300007466)
lang = ['en', 'nl', 'es', 'de', 'fr']
print('Label per language')
print('------------------')
for l in lang:
label = churches.label(l)
print(l + ' --> ' + label.language + ': ' + label.label + ' [' + label.type + ']')
print('All Labels')
print('----------')
for l in churches.labels:
print(l.language + ': ' + l.label + ' [' + l.type + ']')
print('All Notes')
print('---------')
for n in churches.notes:
print(n.language + ': ' + n.note + ' [' + n.type + ']')
Using TGNProvider¶
The TGNProvider
is a provider for
the TGN. It’s use is identical to all other SKOSProviders.
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
This script demonstrates using the TGNProvider to get the concept of
Flanders.
'''
from skosprovider_getty.providers import TGNProvider
aat = TGNProvider(metadata={'id': 'TGN'})
flanders = aat.get_by_id(7018236)
lang = ['en', 'nl', 'es', 'de', 'fr']
print('Label per language')
print('------------------')
for l in lang:
label = flanders.label(l)
print(l + ' --> ' + label.language + ': ' + label.label + ' [' + label.type + ']')
print('Labels')
print('------')
for l in flanders.labels:
print(l.language + ': ' + l.label + ' [' + l.type + ']')
print('Notes')
print('-----')
for n in flanders.notes:
print(n.language + ': ' + n.note + ' [' + n.type + ']')
Finding concepts or collections¶
See the skosprovider_getty.providers.GettyProvider.find()
method for
a detailed description of how this works.
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
This script demonstrates using the AATProvider to find the concepts that are a member of a collection with 'church' in their label
'''
from skosprovider_getty.providers import AATProvider
results = AATProvider({'id': 'AAT', 'default_language': 'nl'}).find({'label': 'church', 'type': 'concept', 'collection': {'id': '300007466', 'depth': 'all'}})
print('Results')
print('------')
for result in results:
print(result)
Using expand()¶
The expand methods return the id’s of all the concepts that are narrower concepts of a certain concept or collection.
See the skosprovider_getty.providers.GettyProvider.expand()
method for
a detailed description of how this works.
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
This script demonstrates using the AATProvider to expand a collection
'''
from skosprovider_getty.providers import AATProvider
results = AATProvider({'id': 'AAT', 'default_language': 'nl'}).expand('300007466')
print('Results')
print('------')
for result in results:
print(result)