A fast and lightweight Python RDF parser which wraps bindings to Rust's Rio using PyO3
Project description
LightRDF
A fast and lightweight Python RDF parser which wraps bindings to Rust's Rio using PyO3.
Features
- Supports N-Triples, Turtle, and RDF/XML
- Handles large-size RDF documents
- Provides HDT-like interfaces
Install
pip install lightrdf
Usage
Iterate over all triples (Parser)
import lightrdf
parser = lightrdf.Parser() # or lightrdf.xml.Parser() for xml
for triple in parser.parse("./go.owl", base_iri=""):
print(triple)
Iterate over all triples (HDT-like)
import lightrdf
doc = lightrdf.RDFDocument("./go.owl")
# ...or lightrdf.RDFDocument("./go.owl", base_iri="", parser=lightrdf.xml.PatternParser) for xml
# `None` matches arbitrary term
for triple in doc.search_triples(None, None, None):
print(triple)
Triple pattern (HDT-like)
import lightrdf
doc = lightrdf.RDFDocument("./go.owl")
for triple in doc.search_triples("http://purl.obolibrary.org/obo/GO_0005840", None, None):
print(triple)
# Output:
# ('http://purl.obolibrary.org/obo/GO_0005840', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2002/07/owl#Class')
# ('http://purl.obolibrary.org/obo/GO_0005840', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://purl.obolibrary.org/obo/GO_0043232')
# ...
# ('http://purl.obolibrary.org/obo/GO_0005840', 'http://www.geneontology.org/formats/oboInOwl#inSubset', 'http://purl.obolibrary.org/obo/go#goslim_yeast')
# ('http://purl.obolibrary.org/obo/GO_0005840', 'http://www.w3.org/2000/01/rdf-schema#label', '"ribosome"^^<http://www.w3.org/2001/XMLSchema#string>')
Benchmark (WIP)
Alternatives
- RDFLib – (Pros) pure-Python, matured, feature-rich / (Cons) takes some time to load triples
- pyHDT – (Pros) extremely fast and efficient / (Cons) requires pre-conversion into HDT
Todo
- Push to PyPI
- Adopt CI
- Handle Base IRI
- Support NQuads and TriG
- Add docs
- Add tests
- Refactor
- Resume on error
- Allow opening fp
License
Rio and PyO3 are licensed under the Apache-2.0 license.
Copyright 2020 Kentaro Ozeki
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
Close
Hashes for lightrdf-0.1.1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd0b416b6902888c814b169e839475051fde1a33560a7b85fda4b0378476a15 |
|
MD5 | b4cd197b04867d228412683bf6412bd8 |
|
BLAKE2b-256 | bcfd5bde726ed016aef1bdf274180a4efed62f89b7cdd3a0eeea4e8f41dec3f6 |
Close
Hashes for lightrdf-0.1.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d79b48a3ebe40b4e39e51ee1d8c142c61a83c64ebae86daec621bac2cb51456 |
|
MD5 | 5548b654927822f10cfb6122dfba6d3c |
|
BLAKE2b-256 | 990fd7bc37b0700a9d0b1c5e37d93313a4beb052d2fd7e95d2939c3468828f47 |
Close
Hashes for lightrdf-0.1.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fc3f0ee875dbc6cd8fb6d836856639a380a55b0653104560245421ed0483cd8 |
|
MD5 | fee464e9c05f0b413a9d3e3c5aae3399 |
|
BLAKE2b-256 | 7fe1c2b59bbdffd9c41a69a2396e016372f02f27adc4c7a4c5e2437a8d6f5441 |
Close
Hashes for lightrdf-0.1.1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfcf8a054934717aabf629c9647f7e7f41c39151e194d8f2d0ce6af2ee420ab2 |
|
MD5 | 1c73844925c92e6ce963151b655cde56 |
|
BLAKE2b-256 | 61faae7fda45f04b23ef098ef99fcca638232d6d15cbe1d985fb38289730f080 |
Close
Hashes for lightrdf-0.1.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8de5bee10e90fe2298e5bd5bf28396789115d3ac0f50042950fb32924f1c9c1b |
|
MD5 | 828c45abfdb524367d8da60a9c2b27eb |
|
BLAKE2b-256 | 9421d17fa65263edcc9f6d49b6d2ede9e79cd4a40ebf685e2d9f5ff551b04737 |
Close
Hashes for lightrdf-0.1.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81acea3bc156b0db3313e6b2220f9eb5846084897bfdeafa944788a0288bf397 |
|
MD5 | 4280793b49ef09f9042d7e9214d45446 |
|
BLAKE2b-256 | 7354bba63486cf0756366c9cfb494b151f62a5d4f769a6bf491b7bc6e6fa1872 |
Close
Hashes for lightrdf-0.1.1-cp36-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7ea34aa5667196c538b726a13981f319e54a6fb1e0f4ac7ba00439578225d7f |
|
MD5 | d86c7e3244da3fef2e05c7610fb335e5 |
|
BLAKE2b-256 | 865a01bb5b97df5beef3bb615ea52b3b0308fe7d2d985cf1fcc5d046ff7fee01 |
Close
Hashes for lightrdf-0.1.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3e0af90aa7ec864532c2bbd92ed1001492f8d15bfaf80dac3797bb0d5bf7666 |
|
MD5 | c284f9de491aeb90e2380a10603fdf64 |
|
BLAKE2b-256 | a8c65f9e3c2a91736a88b5c4fda8674d53d5e31cd2e4fbe1f50e768426dd85b3 |
Close
Hashes for lightrdf-0.1.1-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fc2bf1b97ef6d675f9514b82dcdec16549c4a043cf9adac205cf611fa11f30b |
|
MD5 | 3df8739eb2d7c4aebb6b338248e7eaad |
|
BLAKE2b-256 | ffc898a1a2789c46be229a10a5f824dad24328bda2101d27537149045ba864ed |