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 as configured 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/25893e86-c363-4943-82c4-d4edbcf71fce type: Person name: Jane Doe }