Skip to main content

Github CI

Citation Date Parser

citation-date is a Python library for parsing and normalizing dates from Philippine legal citations, including dockets, reports, and other references. It handles common typos and multiple date formats with US and UK variants. It is eventually used by the dataset employed in LawSQL.

It is deliberately corpus-driven: the grammar preserves observed formatting damage in Supreme Court citation material without trying to guess unrecorded OCR spellings.

Upgrading from 0.2.1? Read the 1.0 release notes for the behavior changes and before/after examples.

Purpose

The library is designed to:

  • Extract dates from text commonly found in legal documents such as Philippine Supreme Court reports (SCRA) and dockets (G.R. No. ...).
  • Handle both US (Month Day, Year) and UK (Day Month Year) date formats.
  • Normalize dates to standard formats (%B %d, %Y or datetime.date).
  • Support dates enclosed in parentheses () or brackets [], and in raw strings.
  • Provide regex patterns and utility functions for downstream processing in other citation libraries.

Key Components

Regex Patterns

US/UK Date Patterns

from citation_date import uk_pattern, us_pattern

assert us_pattern.search("Dec. 1, 2000")
assert uk_pattern.search("1Dec. 2000")

These patterns detect date candidates with compact forms, ordinary punctuation, and the documented duplicate-comma UK variant. They do not match inside a larger alphanumeric token.

Report Dates

  • REPORT_DATE_REGEX matches dates in citations like 1 SCRA 200 (1Dec. 2000).
  • Supports naked dates, bracketed [Dec. 1, 2000], or parenthesis (Dec. 1, 2000).

Docket Dates

  • DOCKET_DATE_REGEX matches docket-specific dates such as G.R. No. 12345, Dec,1, 2000.
  • DOCKET_DATE_FORMAT standardizes formatting to %b. %d, %Y.

Decoding behavior

decode_date() returns the first calendar-valid full date in the text as %B %d, %Y, or as datetime.date when is_output_date_object=True. Unsupported syntax, impossible calendar dates, and year-only report values return None. Compile raw regex constants with re.I | re.X.

Documentation

See the documentation for the regex contracts, decoder reference, and usage paths.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

citation_date-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

citation_date-1.0.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file citation_date-1.0.0.tar.gz.

File metadata

  • Download URL: citation_date-1.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for citation_date-1.0.0.tar.gz
Algorithm Hash digest
SHA256 70d46528b9f295cc0e47bf482a02fc31cc8ebcd948b96828161f4696ccd17e49
MD5 44a6dbb744dc4c9733e2aa64ea8005d8
BLAKE2b-256 2b592b3aae20782517759f85708b79eeadb3ef7583d14b2a80e91fd2bb8f9e8d

See more details on using hashes here.

File details

Details for the file citation_date-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: citation_date-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for citation_date-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5c71553e3c5f0a6ae0584513d8d40e44300859e7c6c03d5b15171a96603b67f
MD5 e3341de859e0fd4d7c59342d5245e1d8
BLAKE2b-256 ce8179aa1cd905174b6dfaa85de3543aca1f8e717311872b739c060139c6ce25

See more details on using hashes here.

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