Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All dates in text #12

Closed
elyase opened this issue Mar 10, 2013 · 10 comments
Closed

All dates in text #12

elyase opened this issue Mar 10, 2013 · 10 comments
Labels

Comments

@elyase
Copy link

elyase commented Mar 10, 2013

Hi, is it possible to recursively look for all dates in a text, for example extract one, eliminate this chunk of text, parse again for the next one, and so on? Any tips on how I should go for this using parsedatetime?

@bear
Copy link
Owner

bear commented Mar 10, 2013

To be honest you can feed the parse() routine whole lines and paragraphs of text and it will locate the date and parse it... but it doesn't report back where it found the date. Most people who want to locate a date normally want to know what text is around the date because they want to extract the context of the date.

This isn't a problem that I've needed to solve so I never coded for it. I've heard of others solving for it by putting chunks of text thru parse() and if a date was found then putting each line thru to narrow down the place.

@elyase
Copy link
Author

elyase commented Mar 10, 2013

ok, thanks for your answer and your great work on this library.

@geoffreyfloyd
Copy link
Collaborator

Hi elyase, if you pull down the latest, you can use the nlp() function. It sounds like this is what you are looking for. It's working quite well and even includes location information of where it was found within the string. Here's an example and the result differences, run @ 9:28 PM on August 2nd:

"I'm so excited!! At 8PM on August 5th i'm going to fly to Florida. Then next Friday at 9PM i'm going to dog n bone! And in 5 minutes i'm going to eat some food!"

Regular parse() function returns this:
((2013, 8, 9, 21, 0, 0, 4, 221, -1), 2)

The nlp() function returns this (a tuple of tuples containing datetime, flag, startpos, endpos, and matchedtext):
((datetime.datetime(2013, 8, 5, 20, 0), 3, 17, 37, 'At 8PM on August 5th'),
(datetime.datetime(2013, 8, 9, 21, 0), 2, 72, 90, 'next Friday at 9PM'),
(datetime.datetime(2013, 8, 2, 21, 33, 18), 2, 120, 132, 'in 5 minutes'))

@bear
Copy link
Owner

bear commented Aug 2, 2013

Geoffrey,

I really really want to add you to the committers for adding this
function - it is something I wanted to do for a long time but never had
time (or a project) for it.

I seriously love this addition to the code!

On Fri, Aug 2, 2013 at 7:00 PM, Geoffrey Floyd notifications@github.comwrote:

Hi elayse, if you pull down the latest, you can use the nlp() function. It
sounds like this is what you are looking for. It's working quite well and
even includes location information of where it was found within the string.
Here's an example and the result differences, run @ 9:28:18 PM on August
2nd:

"I'm so excited!! At 8PM on August 5th i'm going to fly to Florida. Then
next Friday at 9PM i'm going to dog n bone! And in 5 minutes i'm going to
eat some food!"

Regular parse() function returns this:
((2013, 8, 9, 21, 0, 0, 4, 221, -1), 2)

The nlp() function returns this (a tuple of tuples containing datetime,
flag, startpos, endpos, and matchedtext):
((datetime.datetime(2013, 8, 5, 20, 0), 3, 17, 37, 'At 8PM on August 5th'),
(datetime.datetime(2013, 8, 9, 21, 0), 2, 72, 90, 'next Friday at 9PM'),
(datetime.datetime(2013, 8, 2, 21, 33, 18), 2, 120, 132, 'in 5 minutes'))


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-22041789
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@elyase
Copy link
Author

elyase commented Aug 2, 2013

I am also really glad to hear it is implemented, thanks, will try as soon as I have a chance.

@geoffreyfloyd
Copy link
Collaborator

I'd love to be on the committers list! Where do i sign? :)

@bear
Copy link
Owner

bear commented Aug 4, 2013

Nothing to sign, just let me know what your github handle is and I'll add
you

On Fri, Aug 2, 2013 at 7:46 PM, Geoffrey Floyd notifications@github.comwrote:

I'd love to be on the committers list! Where do i sign? :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-22043746
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@geoffreyfloyd
Copy link
Collaborator

geoffreyfloyd

@bear
Copy link
Owner

bear commented Aug 4, 2013

done!

On Sun, Aug 4, 2013 at 7:44 AM, Geoffrey Floyd notifications@github.comwrote:

geoffreyfloyd


Reply to this email directly or view it on GitHubhttps://github.com//issues/12#issuecomment-22070467
.

Bear

bear@xmpp.org (email)
bear42@gmail.com (xmpp, email)
bear@code-bear.com (xmpp, email)
http://code-bear.com/bearlog (weblog)

PGP Fingerprint = 9996 719F 973D B11B E111 D770 9331 E822 40B3 CD29

@bear
Copy link
Owner

bear commented Jul 5, 2015

marking this as closed - I feel that it's been resolved with the nlp() code, if not please do re-open it.

thanks!

@bear bear closed this as completed Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants