Skip to main content

Client interface to sentier.dev sustainability assessment glossary

Project description

sentier_glossary

PyPI Status Python Version License

Read the documentation at https://sentier_glossary.readthedocs.io/ Tests Codecov

pre-commit Black

Installation

You can install sentier_glossary via [pip] from [PyPI]:

$ pip install sentier_glossary

Usage

There is a single class, GlossaryAPI, which wraps the Sentier glossary API endpoints:

from sentier_glossary import GlossaryAPI, CommonSchemes
api = GlossaryAPI()

With this class, you can retrieve the collections (logical organization of concept schemes into products, processes, places, and units), concept schemes, and concepts. For example:

> api.schemes()
[{'iri': 'http://data.europa.eu/z1e/icstcom2009/icst',
  'notation': 'ICST-COM 2009',
  'prefLabel': 'International Classification of Ship by Type (ICST-COM)',
  'scopeNote': ''},
...]
> [
>    concept
>    for concept in api.concepts_for_scheme('http://data.europa.eu/z1e/icstcom2009/icst')
>    if 'passenger' in concept['prefLabel'].lower()
> ]
[{'iri': 'http://data.europa.eu/z1e/icstcom2009/35',
  'identifier': '35',
  'notation': '35',
  'prefLabel': '35 Passenger ship',
  'altLabel': 'Passenger ship',
  'scopeNote': 'Ship categories included: passengers (excluding cruise passengers)...'},
 {'iri': 'http://data.europa.eu/z1e/icstcom2009/36',
  'identifier': '36',
  'notation': '36',
  'prefLabel': '36 Cruise Passenger',
  'altLabel': 'Cruise Passenger',
  'scopeNote': 'Ship categories included: cruise ships only '}]
> api.concept('http://data.europa.eu/z1e/icstcom2009/35')
{'iri': 'http://data.europa.eu/z1e/icstcom2009/35',
 'notation': '35',
 'prefLabel': '35 Passenger ship',
 'identifier': '35',
 'scopeNote': 'Ship categories included: passengers (excluding cruise passengers)...',
 'altLabel': 'Passenger ship',
 'concept_schemes': ['http://data.europa.eu/z1e/icstcom2009/icst'],
 'relations': []}

The Sentier glossary uses vocabularies built on SKOS, and uses SKOS terms like prefLabel, altLabel, broader, narrower, and scopeNote.

Language of Results

The results returned from the API will depend on your language preferences. By default, the glossary client uses the default language in your locale. You can change it when instantiating the API:

api = GlossaryAPI(language_code="fr")

Language codes follow ISO 639-1, and are two lowercase letters, e.g. en, es, and zh.

You can also use set_language_code() to change the language of an existing GlossaryAPI client. For example:

> api.set_language_code('fr')
> api.concept('http://data.europa.eu/z1e/icstcom2009/35')
{'iri': 'http://data.europa.eu/z1e/icstcom2009/35',
 'notation': '35',
 'prefLabel': '35 Passagers',
 'identifier': '35',
 'scopeNote': 'Catégories incluses dans chaque type de navire: Passagers (sauf passagers de navires de croisière)',
 'altLabel': 'Passagers',
 'concept_schemes': ['http://data.europa.eu/z1e/icstcom2009/icst'],
 'relations': []}

The default fallback language of the glossary is en.

Semantic Search

The API search endpoint is under revision; for the time being we can use local semantic search. This only works with concept schemes given in CommonSchemes, currently:

To make a search query, pass the search query and the concept scheme. For example:

> api.semantic_search("piggies", CommonSchemes.cn2024)
[[{'iri': 'http://data.europa.eu/xsp/cn2024/080291000080',
   'identifier': '080291000080',
   'notation': '0802 91 00',
   'prefLabel': '0802 91 00 -- Pignons, en coques',
   'altLabel': '-- Pignons, en coques',
   'scopeNote': 'Pignons, frais ou secs, en coques'}],
...]

The first time you run this it might take a while as it downloads the data needed for semantic search, and vectorizes the API vocabularies.

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, sentier_glossary is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentier_glossary-0.5.2.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentier_glossary-0.5.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file sentier_glossary-0.5.2.tar.gz.

File metadata

  • Download URL: sentier_glossary-0.5.2.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sentier_glossary-0.5.2.tar.gz
Algorithm Hash digest
SHA256 a0863589890dddc19b8fcc07c0ff7770c1a0f2cf4d448363ce5eeca9b3397438
MD5 2938d15c26d85647d9ee8ebbe9037a9c
BLAKE2b-256 a28c0d279197e4fca32265cac127a6da14d7973f84ae8aa6982ea623d6d605ba

See more details on using hashes here.

File details

Details for the file sentier_glossary-0.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sentier_glossary-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2b0c33b6aa59235d31cbf8fa322819ad8057b29583b2aec21ff76b302710c7fa
MD5 63f21b0c8923dd2857f4092e1ec5d816
BLAKE2b-256 85ad7b520d1d39846fd9844db40ed13421d0d367c7d99ca2d79ae9909bf7c433

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page