Skip to main content

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.

Demo

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

hkeyecite-0.1.2.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hkeyecite-0.1.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file hkeyecite-0.1.2.tar.gz.

File metadata

  • Download URL: hkeyecite-0.1.2.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hkeyecite-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fceed593ccff02976c77a875525e6478ee417cfac82f99ca695a0c9a41d5841c
MD5 7d4a822ec176327c0c284829f8940388
BLAKE2b-256 fcfd4a9009e078249739cf8e97b32761ba7207299cdb698fd4a082b0c40d0e07

See more details on using hashes here.

Provenance

The following attestation bundles were made for hkeyecite-0.1.2.tar.gz:

Publisher: publish.yml on terracottalabs/hkeyecite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hkeyecite-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hkeyecite-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hkeyecite-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 daf5b88f41d3f27ee07f9f5e85fc8c1dcb3ab174d1959ac920cf4b29b2b8b07c
MD5 5f326f5908cce4c8ca2b3bbacdb6ed51
BLAKE2b-256 fb7f27ce4a5cb0e7e52c54a48af175297cbb8d7cc85a956c3165a3e986c6ef6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for hkeyecite-0.1.2-py3-none-any.whl:

Publisher: publish.yml on terracottalabs/hkeyecite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page