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.1.tar.gz (5.8 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.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: citation_date-1.0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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.1.tar.gz
Algorithm Hash digest
SHA256 9c74b99c3e3648c92b405de24a49d41fabcd0d6397da55888658020cb3d0f95c
MD5 da5ed36eee7f27d46ccbf932852d933b
BLAKE2b-256 f17998a8ba36a0feb096923b427599f87845916aa3ee6825461b756a4c57eb72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: citation_date-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eea2be7d8bd54039586a2bcc368bf87fd380bd4b13248fbc9936a155eea2d1fc
MD5 59b60c4eaf36c42a4eab4a2b8af975cb
BLAKE2b-256 007b1a20436a74b6f2d00c41f7ddbbbed295b15d4d2b5f4ecc1685047471e734

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