PyLOD
PyLOD is a Python wrapper for exposing Linked Open Data from public SPARQL-served endpoints. It acts as an abstraction layer for the retrieval of structured data, such as classes, properties and individuals, without requiring any knowledge of SPARQL.
Getting Started
PyLOD is a minimal module for Python (2.x. and 3.x).
Prerequisites
SPARQLWrapper - SPARQLWrapper is a simple Python wrapper around a SPARQL service to remotelly execute queries.
Installation
- Install SPARQLWrapper.
- Save
PyLOD.pyto your project's directory.
pip install PyLOD
Usage
1. Import the PyLOD class and create a PyLOD class object.
from PyLOD import PyLOD
pylod = PyLOD()
2. Provide a dictionary of desired namespaces
my_namespaces={
"dbo": "http://dbpedia.org/ontology/",
"dbp": "http://dbpedia.org/property/"
}
pylod.namespaces.set_namespaces(my_namespaces)
This step is optional, since PyLOD already incorporates a set of known namespaces. To get the list of defined namespaces, use this:
print(pylod.namespaces.get_namespaces())
3. Define a dictionary of SPARQL endpoints to be queried:
my_endpoints={
"DBpedia": "http://dbpedia.org/sparql",
"GeoLinkedData": "http://linkedgeodata.org/sparql"
}
pylod.endpoints.set_endpoints(my_endpoints)
If no endpoints are defined, PyLOD will use a pre-defined set of known endpoints. To get the list of these endpoints, do this:
print(pylod.endpoints.get_endpoints())
4. Use PyLOD's expose functions to retrieve structured data from the endpoints.
Set the optional argument limit_per_endpoint to limit the results per endpoint. For example:
# Get entities of type owl:Class
classes = pylod.expose.classes(limit_per_endpoint=100)
# Get the sub-classes of a specific class
sub_classes = pylod.expose.sub_classes(super_class="dbo:Artist")
# Get instances of a specific class
instances = pylod.expose.instances_of_class(cls="dbo:Artist", include_subclasses=True, limit_per_endpoint=50)
# Execute custom SPARQL select query to all endpoints
results = pylod.sparql.execute_select_to_all_endpoints(query="SELECT * WHERE {?s ?p ?o}")
Expose functions:
- classes() - Returns class entities
- sub_classes() - Returns the sub-classes of a given class
- super_classes() - Returns the super-classes of a given class
- equivalent_classes() - Returns the equivalent classes of a given class
- disjoint_classes() - Returns the disjoint classes of a given class
- sub_properties() - Returns the sub-properties of a given property
- super_properties() - Returns the super-properties of a given property
- triples() - Allows the retrieval of triples within the pattern (subject-predicate-object)
- subjects() - Returns the subjects of a given predicate-object pair
- predicates() - Returns the predicates of a given subject-object pair
- objects() - Returns the objects of a given subject-predicate pair
- instances_of_class() - Returns instances of a given class type
- labels() - Returns labels of a given entity, with an optional language argument
SPARQL functions:
- execute_select() - Allows the execution of a custom SPARQL select query to a given endpoint URL
- execute_select_to_all_endpoints() - Allows the execution of a custom SPARQL select query to all endpoints defined in
pylod.endpoints.get_endpoints() - is_active_endpoint() - Checks if a given endpoint URL is alive and responds to SPARQL queries
Documentation
The official webpage - The Docs
Authors
- Panos Mitzias - Design and development
- Stratos Kontopoulos - Contribution to the design
Powered by
- Centre for Research & Technology Hellas - CERTH
- Multimedia Knowledge & Social Media Analytics Laboratory - MKLab
Applications
PyLOD has been deployed in the following projects:
Metadata
Release files for PyLOD 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyLOD-0.1.12.tar.gz | 9.3 kB | Without provenance | Details for PyLOD-0.1.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyLOD-0.1.12-py2-none-any.whl | Python 2 | none | any | Details for PyLOD-0.1.12-py2-none-any.whl |
Total release size: 17.3 kB
Release files / PyLOD-0.1.12.tar.gz
| Download URL | PyLOD-0.1.12.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7096f0868557d19d97407b4e9d6d5ca2d8fee7d08a85013ddc6ce9f0b9fa580f
|
|
BLAKE2b-256 checksum How to use checksums |
8150a40af39abe4c556b24207a0f978bc1ea2fbf77e9a61ace0565e359ca5416
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / PyLOD-0.1.12-py2-none-any.whl
| Download URL | PyLOD-0.1.12-py2-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
6081d1518400752c77d59ff865b74fc04db9410f3b77bc87eead647744eccd14
|
|
BLAKE2b-256 checksum How to use checksums |
cbe92a4ecf3934a469fbd70c63cbb5f8ada24b2a1d254af9087e7e621f287aa3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for PyLOD 0.1.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.