Knowledge Bases
Use knowledge bases to find legal information related to a query.
Last updated
Use knowledge bases to find legal information related to a query.
Last updated
A Knowledge Base (KB) is a database of legal information stored using an embedding database. You can use the retrieve API to query the Knowledge Base for items of legal data that match a query.
Our legislation Knowledge Bases contain the full text of all the digitised legislation that is available through the Laws.Africa Content API. The legislation is split into portions (chapters, sections, paragraphs, etc.) and embeddings are calculated for each portion. These embeddings make it possible to perform semantic queries against the data to find portions relevant to a keyword, phrase or question.
Knowledge Bases include only the most recent version of legislation. See Works and Expressions for more details on how legislation changes over time.
Use the retrieve API to query a Knowledge Base for information matching keywords or phrases.
When you query a knowledge base, you must submit a POST request:
Identify the Knowledge Base to query using its code in the URL of the request.
Specify the text to search the Knowledge Base for using the text
parameter.
The API will return matching items (portions of legislation) that match your query, including a score, the text of the portion, and metadata.
The API returns the text of the matching item, the score of the match (a lower score is better), and metadata for the portion. This provides very precise details on the portion of legislation that matched the query, allowing you to provide concrete citation information to your user.
The metadata includes a combination of:
Details of the legislative work, including FRBR URI information.
Table of Contents information for the portion of that work.
For example:
Get details of Laws.Africa's Knowledge Bases.
Note: this API is a preview and may change in future.
/ai/v1/knowledge-bases
A page number within the paginated result set.
Number of results to return per page.
Get details of Laws.Africa's Knowledge Bases.
Note: this API is a preview and may change in future.
/ai/v1/knowledge-bases/{code}
Unique code identifying this knowledge base
Retrieve items from the knowledge base that match your query.
/ai/v1/knowledge-bases/{code}/retrieve
Unique code identifying this knowledge base
The text to find matching items for
Number of results to return