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.

When an action number appears near a filing or hearing date, the nearby date is captured if it is within 35 characters on either side of the action number. Supported formats include:

  • DD/MM/YYYY, DD.MM.YYYY, DD-MM-YYYY (using a consistent separator)
  • DD Month YYYY (e.g. 3 April 2018) including ordinal suffixes (3rd April 2018), the optional of connector (3rd of April 2018), abbreviated month names (3 Apr 2018), and trailing periods on abbreviations (3 Apr. 2018)

Extracted dates are normalised to ISO format (YYYY-MM-DD). US-style date formats (e.g. MM/DD/YYYY or April 3, 2018) are not supported — this library targets Hong Kong jurisdiction only.

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

Action number citations also have .nearby_date, which is the nearest supported date found within 35 characters before or after the action number, normalised as YYYY-MM-DD. If no nearby date is found, .nearby_date is None.

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.3.tar.gz (19.2 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.3-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hkeyecite-0.1.3.tar.gz
  • Upload date:
  • Size: 19.2 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.3.tar.gz
Algorithm Hash digest
SHA256 498e32784d34f24d6089fb520c032ada815cbbfa9878d5903a194917ebda9ab6
MD5 2fd4e15543132d139f0dfbb6ffa6e32a
BLAKE2b-256 8ed8620826ae20794777ab81efc6b9ba007f74e7aec55752080cb5753dbe1bd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for hkeyecite-0.1.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: hkeyecite-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 18.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3a037de03a8c46bb5856d8f33e3b6975f8f1235395d37c11301fc4aa97ff699a
MD5 04bc610c43bd707441166d9a029311b1
BLAKE2b-256 fc9433c0ec7cc37cc3cf830a7e50b8b4962e97f06ae6c53189bb696c0aa4a023

See more details on using hashes here.

Provenance

The following attestation bundles were made for hkeyecite-0.1.3-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