Skip to main content

A Python binding for the Semantic Analyser service maintained by BODC

Project description

semanticanalyser-py

A lightweight Python client for the BODC Semantic Analyser API. It enables a Python developer to access Semantic Analyser functionalities, including the discovery of controlled vocabularies, exploration of available categories, match types and properties, and execution of term analysis to resolve terms to canonical concepts (with codes and URIs) across marine community vocabularies, including BODC NVS.

The project is authored by Ahmad Mahmoud during his internship at CNR-IIA.

BODC Semantic Analyser homepage: https://semantics.bodc.ac.uk/

BODC Semantic Analyser reference: https://editoria.ingv.it/miscellanea/2024/miscellanea80/

Key features

  • Retrieve semantic categories
  • List supported vocabularies
  • Discover supported match types and match properties
  • Analyse free-text terms and obtain matched concepts, codes, and vocabularies
  • Simple, Pythonic API with minimal dependencies

Installation

pip install semanticanalyser-py

Quick start

Open In Colab

# Basic usage example
from analyser import SemanticAnalyser, Matchtype, MatchProperty

analyser = SemanticAnalyser()  # uses the public BODC endpoint by default

# Explore categories
categories = analyser.get_categories()
print("Categories:", categories)

# Choose a category (e.g., first one) and list vocabularies
if categories:
    cat_code = categories[0]["termCode"]
    vocabs = analyser.get_vocabularies(cat_code)
    for v in vocabs:
        print(v)

# Discover matching options
match_types = analyser.getMatchTypes()         # e.g., ["exact", "broad", ...]
match_props = analyser.getMatchProperties()    # e.g., ["prefLabel", "altLabel", ...]

# Prepare the query
terms = ["dissolved oxygen", "chlorophyll a"]

# Optionally filter or construct match types/properties
# (example below demonstrates using them as returned)
analysis = analyser.analyseTerms(
    terms=terms,
    matchTypes=match_types,
    matchProperties=match_props
)

if analysis:
    for m in analysis.get_matches():
        print(
            m.getMatchingTerm(),
            m.getMatchProperty(),
            m.getMatchType(),
            m.getTermCode(),
            m.getVocabulary(),
            m.getConceptURI(),
        )

When to use this library

  • You need to map free-text terms to standardised concepts and codes
  • You’re enriching marine dataset descriptions with semantic metadata (URIs, codes, vocabularies)

Configuration

  • Endpoint: By default, the client targets the public BODC Semantic Analyser API. You can override the endpoint:
  from analyser import SemanticAnalyser
  analyser = SemanticAnalyser(endpoint="https://semantics.bodc.ac.uk/api")

Requirements

  • Python: 3.8 or newer
  • Dependencies: requests

Roadmap ideas

  • Robust pagination and retry logic
  • Additional helpers for filtering results
  • CLI utilities

Contributing

Issues and pull requests are welcome.

License

GNU GPL-3.0

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

semanticanalyser_py-0.1.7.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

semanticanalyser_py-0.1.7-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file semanticanalyser_py-0.1.7.tar.gz.

File metadata

  • Download URL: semanticanalyser_py-0.1.7.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for semanticanalyser_py-0.1.7.tar.gz
Algorithm Hash digest
SHA256 a62c69f63c7f6dfd56e4c239acccc318442aa906565437816133a378b28f8e8c
MD5 64ead3046f6919307072642de7acc88e
BLAKE2b-256 d7abb9c7d9015c0ed34791150eab2ff96fbc2f9519e53a3129b6ba9fa2d1c931

See more details on using hashes here.

File details

Details for the file semanticanalyser_py-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for semanticanalyser_py-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cc1776a25e139cc924362c64ae7b646e8ce60f776c1bfbccad004153892b7910
MD5 71a5fa87f1e3520cef97274e2c82ac6f
BLAKE2b-256 eeb933a8cfada704147d39354fb937af0dbff2c9a8716af0b2e73e8e603417e8

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