This notebooks demonstrates how to use configured Formatting string patterns to normalise resource identifiers.
from kgforge.core import KnowledgeGraphForge
A configuration file is needed in order to create a KnowledgeGraphForge session. A configuration can be generated using the notebook 00-Initialization.ipynb.
forge = KnowledgeGraphForge("../../configurations/forge.yml")
from kgforge.core import Resource
from uuid import uuid4
uuid = str(uuid4())
uid = forge.format("identifier", "persons", uuid) # here "identifier" is the formatter name while "persons" can be seen as a type
resource = Resource(id=uid, type="Person", name="Jane Doe")
print(resource)
{ id: https://kg.example.ch/persons/b552e6a6-108a-4aaf-9949-dc78f8fa5577 type: Person name: Jane Doe }