Read and query HDT document with ease in Python
Project description
pyHDT
Read and query HDT document with ease in Python
Requirements
gcc/clang with c++11 support
Python Development headers > You should have the Python.h header available on your system. > For example, for Python 3.6, install the python3.6-dev package on Debian/Ubuntu systems.
Then, install the pybind11 library
pip install pybind11
Installation
Installation in a virtualenv is strongly advised!
Pip install (recommended)
pip install hdt
Manual installation
git clone https://github.com/Callidon/pyHDT cd pyHDT/ ./install.sh
Getting started
from hdt import HDTDocument
# Load an HDT file. Missing indexes are generated automatically
document = HDTDocument("test.hdt")
# Display some metadata about the HDT document itself
print("nb triples: %i" % document.get_total_triples())
print("nb subjects: %i" % document.get_nb_subjects())
print("nb predicates: %i" % document.get_nb_predicates())
print("nb objects: %i" % document.get_nb_objets())
print("nb shared subject-object: %i" % document.get_nb_shared())
# Fetch all triples that matches { ?s ?p ?o }
# Use empty strings ("") to indicates variables
(triples, cardinality) = document.search_triples("", "", "")
print("cardinality of { ?s ?p ?o }: %i" % cardinality)
for triple in triples:
print(triple)
# Search also support limit and offset
(triples, cardinality) = document.search_triples("", "", "", limit=10, offset=100)
# etc ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hdt-1.1.0.tar.gz
(214.0 kB
view hashes)
Built Distribution
Close
Hashes for hdt-1.1.0-py3.6-linux-x86_64.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 956aadf56f783d564518ca0ccc148b344f0439a8cdde3ab4c6e4b3866ebbfa23 |
|
MD5 | 063f8a47184f48e61a91bb1a7daf6d0d |
|
BLAKE2b-256 | cd3fc053c893975ebcd20a3321f112dadbf60fa6965c1e592f4313813d5da04a |