Advanced enrichments
Fetching enrichments from the Laws.Africa Enrichments API.
Last updated
Fetching enrichments from the Laws.Africa Enrichments API.
Last updated
Working with the Laws.Africa Enrichments API
Displaying API-based enrichments in a document
We'll be using the for these examples, which has the FRBR URI /akn/za-cpt/act/by-law/2014/control-undertakings-liquor
.
The Laws.Africa Enrichments API provides access to the enrichment datasets. The API endpoint is .
An enrichment is additional data that is associated with an expression, but is not included in the text of the document. Laws.Africa groups common enrichments together as an enrichment dataset. Each enrichment dataset has a taxonomy tree that is used to "tag" (enrich) elements.
In this example we will use the "Tutorial" enrichment dataset provided by the Laws.Africa API.
Name: Tutorial Enrichment Dataset
Taxonomy tree:
Tutorial
Red
Green
Blue
An enrichment is linked to a single provision (element) in a work, identified with the provision's eId.
For example, we can enrich Section 4(1) of the Cape Town Liquor Trading by-law with the taxonomy tag "Red":
work: /akn/za-cpt/act/by-law/2014/control-undertakings-liquor
provision: sec_4__subsec_1
taxonomy topic: red
We need to model enrichments to store them in our Django app's database.
Now create new database migrations and run them to update the database:
Create a new file reader/management/commands/ingest_enrichments.py
:
You will need to provide it with your API token:
We're going to show the enrichments in the gutter, just like we did for the basic enrichments. This time, however, we'll load them when the page loads.
Let's update the expression_detail.html
file to replace the existing la-gutter
as follows:
Now the enrichments (if any) will show in the gutter when the page loads.
The tutorial enrichment dataset only has enrichments for the FRBR URI /akn/za-cpt/act/by-law/2014/control-undertakings-liquor
.
Now let's create a new management command to fetch the Tutorial Dataset from the Enrichments API endpoint .
Try visiting to view the enrichments in your local dataset.