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.1.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.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hkeyecite-0.1.1.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

Hashes for hkeyecite-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f29a7bf12f6d980c98a97c684eb11d607647f7b6b77cddb82e2954e1c0ddb52e
MD5 5a409474f0728a7a46201b1eeb66158b
BLAKE2b-256 151009bec8a5613f6cdbf89510a62f3790eb6c6d0327ef83ba1ac1f3cc9e1380

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: hkeyecite-0.1.1-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

Hashes for hkeyecite-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 491a0e762a3f242bc8a62d51871788c8f4f8c91aac532ea63e882659da98812e
MD5 464183b7597f06ed2ea3b533bca37b95
BLAKE2b-256 d199968014f82caa4f373cb0d3d88fc81963afea81a6605fc7cfc83c53270dfa

See more details on using hashes here.

Provenance

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