Helper functions for the generation of CIDOC CRMish RDF
Project description
acdh-cidoc-pyutils
Helper functions for the generation of CIDOC CRMish RDF
Usage
- install via
pip install acdh-cidoc-pyutils
date-like-string to casted rdflib.Literal
from acdh_cidoc_pyutils import date_to_literal
dates = [
"1900",
"1900-01",
"1901-01-01",
"foo",
]
for x in dates:
date_literal = date_to_literal(x)
print((date_literal.datatype))
# returns
# http://www.w3.org/2001/XMLSchema#gYear
# http://www.w3.org/2001/XMLSchema#gYearMonth
# http://www.w3.org/2001/XMLSchema#date
# http://www.w3.org/2001/XMLSchema#string
make some random URI
from acdh_cidoc_pyutils import make_uri
domain = "https://hansi4ever.com/"
version = "1"
prefix = "sumsi"
uri = make_uri(domain=domain, version=version, prefix=prefix)
print(uri)
# https://hansi4ever.com/1/sumsi/6ead32b8-9713-11ed-8065-65787314013c
uri = make_uri(domain=domain)
print(uri)
# https://hansi4ever.com/8b912e66-9713-11ed-8065-65787314013c
create an E52_Time-Span graph
from acdh_cidoc_pyutils import create_e52, make_uri
uri = make_uri()
e52 = create_e52(uri, begin_of_begin="1800-12-12", end_of_end="1900-01")
print(e52.serialize())
# returns
# @prefix ns1: <http://www.cidoc-crm.org/cidoc-crm/> .
# @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
# @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
# <https://hansi4ever.com/387fb457-971b-11ed-8065-65787314013c> a ns1:E52_Time-Span ;
# rdfs:label "1800-12-12 - 1900-01"^^xsd:string ;
# ns1:P82a_begin_of_the_begin "1800-12-12"^^xsd:date ;
# ns1:P82b_end_of_the_end "1900-01"^^xsd:gYearMonth .
development
pip install -r requirements_dev.txt
flake8
-> lintingcoveage run -m pytest
-> runs tests and creates coverage stats
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
acdh_cidoc_pyutils-0.2.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for acdh_cidoc_pyutils-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50f38a5fa872d2d634f3396cc879ab77dd2b2fd4b49a9c4d22dadd12bba7ac74 |
|
MD5 | 8b2d547bce9d7a33f695bcce1661a3fe |
|
BLAKE2b-256 | aea21bfe18c0500d0087cbeff5d0bec2d40e51ccb48e0e53a64c108a882f7a10 |