Skip to content

[QUESTION] Can search_dates be used to find matches involving two times? #855

Open
@lewtun

Description

@lewtun

Hello,

First of all, thank you for creating such a nifty general-purpose date/time parser!

I have some texts where the events are defined over two times, e.g. something like

text = "On Monday, December 9 from 10:00 to 15:00 we will deploy FizzBuzzAI to prod"

Currently search_dates is working well at capturing the date, but only returns times for the remainder, i.e.

from dateparser.search import search_dates
search_dates(text)
# output
[('On Monday, December 9', datetime.datetime(2020, 12, 9, 0, 0)),
 ('10:00', datetime.datetime(2020, 12, 9, 10, 0)),
 ('15:00', datetime.datetime(2020, 12, 9, 15, 0))]

What I would like to get as output is two events, one for the start / end of the time period:

event 1: datetime.datetime(2020, 12, 9, 10, 0)
event 2: datetime.datetime(2020, 12, 9, 15, 0)

I can achieve this with some post-processing, but I am curious whether this can be done directly in dateparser?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions