A library for extracting and parsing legal citations from Hong Kong court judgments
Project description
hkeyecite
A Python library that automatically finds and extracts legal citations from Hong Kong court judgments.
Give it any block of text containing Hong Kong legal references, and it will identify and parse:
- Neutral citations -- e.g.
[2024] HKCFA 1 - Law report citations -- e.g.
(2019) 22 HKCFAR 446 - Action numbers -- e.g.
HCAL 1756/2020
It also extracts case names (e.g. "HKSAR v Harjani") and pinpoint references (e.g. "at [45]") when present.
Installation
pip install hkeyecite
Requires Python 3.10 or later.
What it recognises
Neutral citations
The format used by the Judiciary since 2018: [Year] Court Number
| Code | Court |
|---|---|
HKCFA |
Court of Final Appeal |
HKCA |
Court of Appeal |
HKCFI |
Court of First Instance |
HKDC |
District Court |
HKFC / HKFamC |
Family Court |
HKLT / HKLdT |
Lands Tribunal |
HKCT |
Competition Tribunal |
HKLBT / HKLaT |
Labour Tribunal |
HKSCT |
Small Claims Tribunal |
HKOAT |
Obscene Articles Tribunal |
HKCC |
Coroner's Court |
HKMC / HKMagC |
Magistrates' Courts |
CFA / CA / CFI |
Older alternate codes |
Law report citations
References to published law report series: (Year) Volume Reporter Page
| Code | Report Series |
|---|---|
HKCFAR |
Hong Kong Court of Final Appeal Reports |
HKLRD |
Hong Kong Law Reports & Digest |
HKC |
Hong Kong Cases |
HKPLR |
Hong Kong Public Law Reports |
HKLR |
Hong Kong Law Reports (historical) |
HKCLR |
Hong Kong Criminal Law Reports |
HKCLRT |
Hong Kong Chinese Law Reports & Translations |
Dotted variations (e.g. H.K.L.R.D., H.K.C.F.A.R.) are automatically normalised.
Action numbers
Case filing references: Prefix Number/Year
Common prefixes include FACV, FACC (Court of Final Appeal), CACV, CACC (Court of Appeal), HCA, HCAL, HCCC (Court of First Instance), DCCJ, DCCC (District Court), and many more.
Metadata
When a citation is preceded by a case name like HKSAR v Harjani or Re Something, it is automatically extracted. Pinpoint references that follow a citation (at [45], at para 10, at p. 5) are also captured.
API
get_citations(text)
The main function. Returns a list of citations found in the text, sorted by position.
from hkeyecite import get_citations
citations = get_citations(text)
Each citation has:
.matched_text-- the original text that was matched.normalized()-- a standardised form of the citation.case_name-- the case name, if one appears before the citation.pin_cite-- the pinpoint reference (e.g. paragraph number), if one follows.start,.end-- character positions in the source text
Pass include_action_numbers=False to skip action number extraction.
Convenience functions
from hkeyecite.find import extract_neutral_citation, extract_reported_citations, extract_action_numbers
# Extract only one type
neutral = extract_neutral_citation(text)
reported = extract_reported_citations(text)
actions = extract_action_numbers(text)
Court and reporter lookup
from hkeyecite.courts import get_court_by_code, get_court_by_case_prefix
from hkeyecite.reporters import get_reporter
court = get_court_by_code("HKCFA")
court.name # "Court of Final Appeal"
court.name_zh # "終審法院"
court = get_court_by_case_prefix("FACV")
court.code # "HKCFA"
reporter = get_reporter("HKCFAR")
reporter.name # "Hong Kong Court of Final Appeal Reports"
Limitations
- Only Hong Kong citations are supported -- UK, Australian, and other jurisdictions are not covered
- Case names in Chinese characters are not extracted
- Some older or non-standard citation formats may not be recognised
Contributing
Pull requests are welcome. If you find a citation format that isn't recognised or have ideas for improvement, feel free to open an issue or PR.
Acknowledgments
This project is derived from eyecite, a citation extraction library for US legal citations by the Free Law Project. hkeyecite adapts eyecite's approach for the Hong Kong jurisdiction, covering HK-specific courts, law reports, action number formats, and neutral citation conventions.
License
BSD 2-Clause License -- see LICENSE.txt for details.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hkeyecite-0.1.0.tar.gz.
File metadata
- Download URL: hkeyecite-0.1.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94a015bbea8ed51fd6f8d4c8450bb38cd8a0431d31c3e4e99e3dcffe0afd3607
|
|
| MD5 |
bcaa59dd33ffd221facd49aa046b09f3
|
|
| BLAKE2b-256 |
3f3494b5a72a8e864bb9b48352df1f90e5885e7ca5ded27b39bad9ce68190c7a
|
Provenance
The following attestation bundles were made for hkeyecite-0.1.0.tar.gz:
Publisher:
publish.yml on terracottalabs/hkeyecite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hkeyecite-0.1.0.tar.gz -
Subject digest:
94a015bbea8ed51fd6f8d4c8450bb38cd8a0431d31c3e4e99e3dcffe0afd3607 - Sigstore transparency entry: 1190278445
- Sigstore integration time:
-
Permalink:
terracottalabs/hkeyecite@a70a8e7effd0a72efc0ee05108c797e4fdb872ed -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/terracottalabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a70a8e7effd0a72efc0ee05108c797e4fdb872ed -
Trigger Event:
release
-
Statement type:
File details
Details for the file hkeyecite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hkeyecite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4f1ab9e1d3ef75cbcffcd662a55c6174bdcac3687585bd310b8bce533929022
|
|
| MD5 |
79600708c867bc4924fdf8e6a6f2e911
|
|
| BLAKE2b-256 |
0007b8384600eec91ccae083d7aca6a8173f79940d4377b6628279bd7e265168
|
Provenance
The following attestation bundles were made for hkeyecite-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on terracottalabs/hkeyecite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hkeyecite-0.1.0-py3-none-any.whl -
Subject digest:
a4f1ab9e1d3ef75cbcffcd662a55c6174bdcac3687585bd310b8bce533929022 - Sigstore transparency entry: 1190278524
- Sigstore integration time:
-
Permalink:
terracottalabs/hkeyecite@a70a8e7effd0a72efc0ee05108c797e4fdb872ed -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/terracottalabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a70a8e7effd0a72efc0ee05108c797e4fdb872ed -
Trigger Event:
release
-
Statement type: