Extracts metadata from legal citations
Project description
legal_citation_parser v 0.2.1
Extracts metadata from legal citations.
Although legal citations are typically short strings, they contain a great deal of information compressed into a relatively small package. This Python module is designed to extract and standardize that data from from legal citation strings. This module can currently handles the following citation types:
- Neutral citations (Canadian);
- Supreme Court Reader (SCR) citations;
- CanLII citations.
Metadata
Basic citation string
The module currently extracts the following from (most) raw CanLII citation strings:
- UID. The decision's unique ID. Corresponds to the CanLII API's
caseId
variable. - Atomic citation. The citation's human readable unique ID.
- Style of cause. The human readable case name.
- Citation type. The type of citation parsed.
- Year. The decision's year.
- Decision number. The decision's number.
- Jurisdiction. The province, territory, or federal jurisdiction the case was heard in.
- Court name. The human readable court level.
- Court level. The relative level of the court.
- CanLII URL. The decision's URL on canlii.org
CanLII API
The module is also able to use the CanLII API to retrieve additional metadata and other potentially useful case information, including:
- Short URL. The decision's short URL.
- Language. The decision's language or languages.
- Docket number. The decision's docket number or numbers.
- Decision date. The YYYY-MM-DD the court issued the decision.
- Keywords. A 'list' of keywords supplied by CanLII, separated by a '—'.
- Categories. A 'list' of categories supplied by CanLII, also separated by a '—'.
- Cases cited. A list of decisions (including databaseId, caseId, title, and citation) the case cites.
- Cases citing. A list of decisions (including databaseId, caseId, title, and citation) that cite the case.
Installation
pip
From the command line:
pip install legal_citation_parser
In Python 3.x:
>>> from legal_citation_parser import parse_citation
Example call:
parse_citation("R v Sutherland, 2022 MBCA 23", include_url=True, call_api_metadata=True)
Should produce:
{'uid': '2022mbca23',
'style_of_cause': 'R v Sutherland',
'atomic_citation': '2022 MBCA 23',
'citation_type': 'neutral',
'scr_citation': None,
'year': '2022',
'court': 'mbca',
'decision_number': '23',
'jurisdiction': 'manitoba',
'court_name': 'Court of Appeal of Manitoba',
'court_level': 'provincial appellate',
'url': 'https://www.canlii.org/en/mb/mbca/doc/2022/2022mbca23/2022mbca23.html',
'short_url': 'https://canlii.ca/t/jmnrg',
'language': 'en',
'docket_number': 'AR21-30-09591',
'decision_date': '2022-02-24',
'keywords': 'Criminal law — Murder — Second degree murder — Evidence — Admissibility',
'categories': 'Criminal or statutory infractions — Evidence — Practice and procedure'}
Example call:
parse_citation("R v Sutherland, 2022 MBCA 23", call_api_cases_cited=True)
Should produce:
{'uid': '2022mbca23',
'style_of_cause': 'R v Sutherland',
'atomic_citation': '2022 MBCA 23',
'citation_type': 'neutral',
'scr_citation': None,
'year': '2022',
'court': 'mbca',
'decision_number': '23',
'jurisdiction': 'manitoba',
'court_name': 'Court of Appeal of Manitoba',
'court_level': 'provincial appellate',
'cited_cases': {'citedCases': [{'databaseId': 'csc-scc',
'caseId': {'en': '1956canlii541'},
'title': 'Chibok v. The Queen',
'citation': '1956 CanLII 541 (SCC)'},
{'databaseId': 'nbca',
'caseId': {'en': '2021nbca3'},
'title': 'Currie v. R.',
'citation': '2021 NBCA 3 (CanLII)'},
{'databaseId': 'csc-scc',
'caseId': {'en': '1982canlii33'},
'title': 'Graat v. The Queen',
'citation': '1982 CanLII 33 (SCC), [1982] 2 SCR 819'},
{'databaseId': 'onca',
'caseId': {'en': '2018onca494'},
'title': 'R. v. Ajise',
'citation': '2018 ONCA 494 (CanLII)'},
...
}
v 0.2.1 updates
- Added functionality to the CanLII API call tool
- Updated the court code dictionaries using the CanLII API
Contributing
Contributions to improve this module are welcome. You can contribute by:
- Reporting bugs
- Suggesting enhancements
- Sending pull requests with bug fixes or new features
License
This project is licensed under the GPL 3.0 License - see the LICENSE file for details.
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
Built Distribution
Hashes for legal_citation_parser-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f674c80d47e34cf07f0d49a7effd421435f9fe62152b8fc7f973e1b61742657e |
|
MD5 | 677ff3287bc4a8f0ce0121db43870e3d |
|
BLAKE2b-256 | 6583dd4dc9f28de67a6e39ecc03c79a3e59969290ee778d76bf0702701193efd |
Hashes for legal_citation_parser-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa2890e10b07241fb2dc507b1269af1deda7d314282e9e9d2e4c110e3d8a5172 |
|
MD5 | 37c511cf95db24197b9d8adbcd9dd1c2 |
|
BLAKE2b-256 | 9b65d1981a0e084e3e3788fa3949b4eb5389c882fce14c3641311a7dc7de5ecb |