Skip to main content

easysparql

A python wrapper to easily query knowledge graphs with SPARQL

Python 3.6

Install

via setuptools

python setup.py

via pip

pip install easysparql

Run tests

python -m unittest discover

To publish

python setup.py sdist bdist_wheel
twine upload dist/*

Functions

  • run_query: run a sparql query.
  • get_entities: get candidate entities of the given name (exact match).
  • get_classes: get classes of a given entity.
  • get_parents_of_class: get direct parent classes of a given class.
  • get_subjects: Get the number of subjects of a given class.
  • get_properties_of_subject: Get the properties of a given subject.
  • get_numerics_from_list: Get the numbers from a list of strings and numbers (if they are more that the provided percentage).
  • get_num: Get the number of a given number/string or None (if it was not a number).

Example

from easysparql import easysparql

DBPEDIA_ENDPOINT = "https://dbpedia.org/sparql"

albert_uri = "http://dbpedia.org/resource/Albert_Einstein"
albert_name = "Albert Einstein"
scientist = "http://dbpedia.org/ontology/Scientist"
foaf_name = "http://xmlns.com/foaf/0.1/name"


classes = easysparql.get_classes(albert_uri, DBPEDIA_ENDPOINT)

entities = easysparql.get_entities(albert_name, DBPEDIA_ENDPOINT, "@en")

parents = easysparql.get_parents_of_class(scientist, DBPEDIA_ENDPOINT)

query = "select distinct ?Concept where {[] a ?Concept} LIMIT 100"
results = easysparql.run_query(query, DBPEDIA_ENDPOINT)

subjects = easysparql.get_subjects(class_uri=scientist, endpoint=DBPEDIA_ENDPOINT)

properties = easysparql.get_properties_of_subject(subject_uri=albert_uri, endpoint=DBPEDIA_ENDPOINT)

a =  ["1.2","2","4","3",3,6,"a","b", "ccc", "1jasdf"]
nums = easysparql.get_numerics_from_list(a, 0.5)

Metadata

Release files for easysparql 1.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easysparql 1.6.2
File Size Uploaded
easysparql-1.6.2.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easysparql 1.6.2
File Interpreter ABI Platform
easysparql-1.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.1 kB

Release files / easysparql-1.6.2.tar.gz

Download URL easysparql-1.6.2.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
328a15a2c8cd6b99ffaf6586781b01191d5c2fc8c01907956a984e408140a20a
BLAKE2b-256 checksum
How to use checksums
f29064c75fd2815d9169b9ab4462280d832d9352a149cf70156c8207fa92801d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.2

Release files / easysparql-1.6.2-py3-none-any.whl

Download URL easysparql-1.6.2-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
651fdd48a708d0bf601f86c0eb726b91ec01ed221aa7859fdda2d90ef652838b
BLAKE2b-256 checksum
How to use checksums
029c13af98653e7faf7ea91a73b30f223dac3afe14b430c878b9a144cfdfc068
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.6.2 This release

2 release files

1.6.1

1 release file

1.6.0

1 release file

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

3 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page