Philippine statutory law pattern matching and unit retrieval.
Project description
statute-utils
Philippine statutory law pattern matching and unit retrieval; utilized in LawSQL dataset.
Documentation
See documentation.
Development
Checkout code, create a new virtual environment:
poetry add statute-utils # python -m pip install statute-utils
poetry update # install dependencies
poetry shell
Some unit patterns
{
"units": [
{
"item": "Container 1",
"content": "Appropriation laws are excluded.",
}
]
}
UNITS_NONE = [
{
"item": "Container 1",
"content": "Individual provisions not detected.",
}
]
Use in Datasette
Add units to a database from a pre-made file
Consider an example db.sqlite
:
>>> from sqlite_utils import Database
>>> from statute_utils import Statute
>>> f = Path().joinpath(path-to-file.yml)
>>> db = Database('db.sqlite')
>>> db["statutes"].insert(Statute.from_file(f).make_row())
# this will contain an 'html' column containing a semantic tree structure that can be styled via css
Copy html/css files
tree.html
- Tree-building macros (which can be used for creating an html tree to represent the statute)tree.css
- Sample css rulesets to use for the tree generated with the macros
Copy files to the Jinja environment where these can be reused:
- /app
--|
|--/static
|--tree.css # copy it here
|--/templates
|--tree.html # copy it here
|--db.sqlite
When datasette is served with:
datasette serve db.sqlite --template-dir=app/templates/ --static static:app/static
It becomes possible to import the macros file into a future files:
{% from 'tree.html' import create_branches %}
{{ create_branches(units|from_json) }} {# note that from_json is custom filter added in the Datasette environment as a one-off plugin}
Add filters / custom functions
Create a file in the plugins directory:
- /app
- /app
--|
|--/static
|--tree.css
|--/templates
|--tree.html
|--/plugins
|--tree.py # new
|--db.sqlite
When datasette is served with:
datasette serve db.sqlite --plugins-dir=app/plugins/ {# plus the other arguments #}...
It becomes possible to use custom functions and filters found in tree.py
.
Changes
- em / strong no longer with label
- Need to add href on <a.label/>
span.par-branch
converted toa.par-branch
- <li#id> and <span#id> changed to <a[data-slug]/>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
statute_utils-0.6.8.tar.gz
(31.2 kB
view hashes)
Built Distribution
Close
Hashes for statute_utils-0.6.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbb5f23cd8e80ff8280e54698b6cc899d48ec709053cf2a71680c094bd45f299 |
|
MD5 | a332abf90b9f859a811a2fd0607f4a58 |
|
BLAKE2b-256 | 02c76c25bc75c7dea5098e796776ae5d41e61d2c3b4ba4f7c1fc814f9e6ea251 |