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.

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

us = rf"({month}{separator}{day}{separator}{year})"
uk = rf"({day}{separator}{month}{separator}{year})"

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-0.3.0.tar.gz (5.2 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-0.3.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: citation_date-0.3.0.tar.gz
  • Upload date:
  • Size: 5.2 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-0.3.0.tar.gz
Algorithm Hash digest
SHA256 fd14d75c2090fc31eb29dd866193f5a58e2e2c03a9bf27f0a7b1ade4c780a3b6
MD5 c11a5a64572887c933c1d3b7f7eb0f12
BLAKE2b-256 71780f852b048285222cead555874b68f3e85286fb1c2ed4a02d005f3ac1cb06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: citation_date-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fbfa5dcdaba073c93daa2aaa2286d3ea19d594a1df23748059663f676fd0087
MD5 923af2c87b0b3b759babaa1380f2947c
BLAKE2b-256 64309c4ff587fc9cec3c9f774a5e0151bbc17bad4640981e530aaa674123330c

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