Skip to content

kg_schema

KGSchema

Stores a Graph object and some metadata corresponding to a KG schema

Source code in exe_kg_lib/classes/kg_schema.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class KGSchema:
    """
    Stores a Graph object and some metadata corresponding to a KG schema
    """

    def __init__(self, path: str, namespace: str, namespace_prefix: str):
        self.path = path  # path of the KG schema definition, can be local or remote
        self.namespace = Namespace(namespace)
        self.namespace_prefix = namespace_prefix

        self.kg = Graph(bind_namespaces="rdflib")
        self.kg.parse(self.path, format="n3")

    @classmethod
    def from_schema_info(cls, schema_info: Dict[str, str]):
        return cls(schema_info["path"], schema_info["namespace"], schema_info["namespace_prefix"])

Last update: October 20, 2023