简体   繁体   中英

Python: How to extract time date specific information from text/nltk_contrib timex.py bug

I am new to python. I am looking for ways to extract/tag the date & time specific information from text eg
1.I will meet you tomorrow
2. I had sent it two weeks back 3. Waiting for you last half an hour

I had found timex from nltk_contrib, however found couple of problems with it https://code.google.com/p/nltk/source/browse/trunk/nltk_contrib/nltk_contrib/timex.py

b. Not sure of the Date data type passed to ground(tagged_text, base_date)

c. It deals only with date ie granularity at day level. Cant find expression like next one hour etc.

Thank you for your help

b) The data type that you need to pass to ground(tagged_text, base_date) is an instance of the datetime.date class which you'd initialize using something like:

from datetime import date
base_date = date.today()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM