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.
This easiest way to install this library is through pip.
$ pip install skosprovider_getty
This will download and install skosprovider_getty
and a few libraries it
depends on.
Using the providers¶
A provider provides access to a single thesaurus or conceptscheme. You can
use the skosprovider_getty.providers.GettyProvider
directly
by passing it a set of configuration options. Or you can use the more specific
subclasses that come pre-configured with some of the configuration. For most
users, this is the preferred method.
Using AATProvider¶
The AATProvider
is a provider for
the AAT. Its use is identical to all other SKOSProviders.
#!/usr/bin/python
'''
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')
langs = ['en', 'nl', 'es', 'de', 'fr']
print('Label per language')
print('------------------')
for lang in langs:
label = churches.label(lang)
print(lang + ' --> ' + label.language + ': ' + label.label + ' [' + label.type + ']')
print('All Labels')
print('----------')
for lang in churches.labels:
print(lang.language + ': ' + lang.label + ' [' + lang.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. Its use is identical to all other SKOSProviders.
#!/usr/bin/python
'''
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)
langs = ['en', 'nl', 'es', 'de', 'fr']
print('Label per language')
print('------------------')
for lang in langs:
label = flanders.label(lang)
print(lang + ' --> ' + label.language + ': ' + label.label + ' [' + label.type + ']')
print('Labels')
print('------')
for lang in flanders.labels:
print(lang.language + ': ' + lang.label + ' [' + lang.type + ']')
print('Notes')
print('-----')
for n in flanders.notes:
print(n.language + ': ' + n.note + ' [' + n.type + ']')
Using ULANProvider¶
The ULANProvider
is a provider for
the ULAN. Its use is identical to all other SKOSProviders.
#!/usr/bin/python
'''
This script demonstrates using the ULANProvider to get the concept of
J.R.R. Tolkien.
'''
from skosprovider_getty.providers import ULANProvider
ulan = ULANProvider(metadata={'id': 'ULAN'})
tolkien = ulan.get_by_id(500112201)
langs = ['en', 'nl', 'und']
print('Label per language')
print('------------------')
for lang in langs:
label = tolkien.label(lang)
print(lang + ' --> ' + label.language + ': ' + label.label + ' [' + label.type + ']')
print('Labels')
print('------')
for lang in tolkien.labels:
print(lang.language + ': ' + lang.label + ' [' + lang.type + ']')
Finding concepts or collections¶
See the skosprovider_getty.providers.GettyProvider.find()
method for
a detailed description of how this works.
#!/usr/bin/python
'''
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
'''
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)