Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Time interval parsing issues #131

Open
vovanec opened this issue Jan 18, 2023 · 0 comments
Open

Time interval parsing issues #131

vovanec opened this issue Jan 18, 2023 · 0 comments

Comments

@vovanec
Copy link

vovanec commented Jan 18, 2023

  • ctparse - Parse natural language time expressions in pytho version:
  • Python version: 3.9.7
  • Operating System: Mac OS

Description

When parsing time intervals and am/pm is not specified for start time, ctparse assumes it's AM. However for people (at least in US) it's very natural to specify interval in format like "3-5PM" or "from 3 to 5PM", assuming both start and end are the same time period.

What I Did

>>> ts
datetime.datetime(2023, 1, 18, 0, 0)
>>> ctparse('3-5pm', ts=ts)
CTParse(2023-01-18 03:00 (X/X) - 2023-01-18 17:00 (X/X), (131, 125, 131, 'ruleHHMM', 'ruleHHMM', 'ruleTODTOD'), -0.43965638477402536)
>>> ctparse('between 3 and 5pm', ts=ts)
CTParse(2023-01-18 03:00 (X/X) - 2023-01-18 17:00 (X/X), (101, 131, 125, 131, 'ruleHHMM', 'ruleHHMM', 'ruleTODTOD', 'ruleAbsorbFromInterval'), 0.11287064948939474)
>>> ctparse('from 3 to 5pm', ts=ts)
CTParse(2023-01-18 03:00 (X/X) - 2023-01-18 17:00 (X/X), (101, 131, 125, 131, 'ruleHHMM', 'ruleHHMM', 'ruleTODTOD', 'ruleAbsorbFromInterval'), 0.11287064948939474)

In the above examples, I expected start time to be resolved to 15:00, not 3:00. Maybe some optional argument to ctparse could be added to customize this behavior?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant