Registry / data / ctparse

ctparse

JSON →
library0.3.6pypypi✓ verified 86d ago

Ctparse is a Python library for parsing natural language time expressions (like 'next Tuesday at 3pm', 'in two weeks', '3rd of March'). Version 0.3.6 is the latest release, with no recent updates. The project appears to be in maintenance mode.

pip install ctparse
INSTALL
IMPORT
SIG · CTPARSE
C
ctparse
datapythonv0.3.6
Install
2.4s avg
Import
656ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.666s · 22.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.646s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ctparse
from ctparse import ctparse
Direct import of main function
parse_time_expression
from ctparse import parse_time_expression
Wrong: no such function exists

Parse a natural language time expression with a reference timestamp.

from ctparse import ctparse from datetime import datetime result = ctparse('next Friday at 5pm', reference_ts=datetime.now()) if result: print(result) else: print('No parse')
Debug
Known issues
gotchactparse returns a list of results (or empty list), not a single object. Always check the list.
fix
Check if result list is non-empty before accessing result[0].
affects: all
gotchaThe function ctparse() requires a 'reference_ts' parameter (a datetime object) to resolve relative times. Without it, parsing 'today' or 'tomorrow' may be ambiguous.
fix
Always pass reference_ts=datetime.now() or similar.
affects: all
deprecatedThe old import 'from ctparse import ctparse' is correct, but some older examples use 'from ctparse import parse'. That function no longer exists.
fix
Use 'from ctparse import ctparse'.
affects: <0.3
breakingIn version 0.3, the internal rule engine was rewritten. Some expressions that worked in 0.2 may no longer parse.
fix
Review patterns; if something fails, file an issue on GitHub.
affects: 0.3
Errors
Common errors & fixes
ImportError: cannot import name 'parse' from 'ctparse'
Old import path from early examples or documentation.
fix
Use 'from ctparse import ctparse'.
ctparse('next week') returns an empty list
Missing reference timestamp or ambiguous expression not handled by grammar.
fix
Pass reference_ts=datetime.now() or try a more specific expression like 'next Monday'.
TypeError: ctparse() missing 1 required positional argument: 'reference_ts'
reference_ts is required in newer versions.
fix
Always provide reference_ts parameter as a datetime object.
Upgrade
Version history
0.3.6latest on PyPI · released Nov 28, 2022
Audit
Dependencies
benedictoptionalFor handling dictionary operations
python-dateutilrequiredDate/time parsing
regexrequiredRegex operations
lark-parserrequiredParsing grammar
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
ctparse — pip install ctparse · libregistry