No project description provided
Project description
CLiSN <:books:>:sparkles:
A collection of RDFLib namespaces for the Computational Literary Studies Infrastructure project.
Requirements
- Python >=3.11
Installation
pip install clisn
Usage
Namespaces
CLiSN provides rdflib.Namespaces
for the CLSInfra project.
from rdflib import Graph
from rdflib.namespace import RDF
from clisn import crm, crmcls, corpus_base
base_ns = corpus_base("SweDraCor")
attrassign_uri = base_ns["attrassign/1"]
triples = [
(
attrassign_uri,
RDF.type,
crm["E13_Attribute_Assignment"]
),
(
attrassign_uri,
crm["P140_assigned_attribute_to"],
base_ns["corpus"]
),
(
attrassign_uri,
crm["P177_assigned_property_of_type"],
crmcls["Z8_corpus_has_corpus_type"]
)
]
graph = Graph()
for triple in triples:
graph.add(triple)
print(graph.serialize())
Output:
@prefix ns1: <http://www.cidoc-crm.org/cidoc-crm/> .
<https://swedracor.clscor.io/entity/attrassign/1> a ns1:E13_Attribute_Assignment ;
ns1:P140_assigned_attribute_to <https://swedracor.clscor.io/entity/corpus> ;
ns1:P177_assigned_property_of_type <https://clscor.io/ontologies/CRMcls/Z8_corpus_has_corpus_type> .
NamespaceManager
clisn
features a custom NamespaceManager for CLSInfra namespaces.
This e.g. allows to easily generate a namespaced rdflib.Graph
like so:
from rdflib import Graph, URIRef, Literal
from clisn import CLSInfraNamespaceManager, crm
graph = Graph()
CLSInfraNamespaceManager(graph)
graph.add(
(
URIRef("https://subject.xyz/example/"),
crm["p90_has_value"],
Literal("some value")
)
)
print(graph.serialize())
Output:
@prefix crm: <http://www.cidoc-crm.org/cidoc-crm/> .
<https://subject.xyz/example/> crm:p90_has_value "some value" .
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
clisn-0.1.4.tar.gz
(14.6 kB
view hashes)
Built Distribution
clisn-0.1.4-py3-none-any.whl
(15.3 kB
view hashes)