Skip to main content

Read and query HDT document with ease in Python

Project description

pyHDT

Build Status Documentation Status PyPI version

Read and query HDT document with ease in Python

Online Documentation

Requirements

  • git

  • pip

  • gcc/clang with c++11 support

  • Python Development headers > You sould have the Python.h header available on your system. > For example, for Python 3.4, install the python3.4-dev package on Debian/Ubuntu systems.

Installation

Installation in a virtualenv is strongly advised!

Pip install (recommanded)

pip install hdt

Quick install

curl https://github.com/Callidon/pyHDT/blob/master/install.sh -sSf | sh

Manual installation

git clone --recursive https://github.com/Callidon/pyHDT
cd pyHDT/
pip install -r requirements.txt
python setup.py install

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


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.0.4.tar.gz (179.5 kB view hashes)

Uploaded source

Built Distributions

hdt-1.0.4-py3.6-linux-x86_64.egg (4.1 MB view hashes)

Uploaded 3 6

hdt-1.0.4-py2.7-linux-x86_64.egg (4.1 MB view hashes)

Uploaded 2 7

Supported by

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