nlp - How to parse temporal expressions (esp. time ranges), Python? -


i have nlp task has 3 components. tried few methods (mentioned in end) not able results.

  1. detecting temporal expressions in statement
  2. classifying either time stamp, time trigger or time period.
  3. equate each expression datetime equivalent.

example:

taking reference time 2000 hrs, thursday, july 20th, 2015

  1. time stamp :

    i want book cab 20 minutes now

    answer: [tstamp]2020 hrs, thursday, july 20th 
  2. time trigger :

    any timer after 2 fine

    answer:  [ttrigger] - start - 0200 hrs,july 21st 2015 

    before 5 good

    [ttrigger] - start - now, 2000hrs, july 20th, 2015 : end - 0500 hrs, july 21st, 2015 
  3. time period:

    i working in san francisco last 2 years

    [tperiod] -  2013-2015 

i tried regex gives generic results. second option read try make model learn naive bays classifier naive bays learns exact words , not phrases.

i came across parsedatetime 1.5 package in python awesome extent in converting phrases timestamps solves 3. of mentioned problem still not able solve detention , classification.

there's python wrapper stanford's corenlp library, includes sutime tool. check out online sutime demo see if can useful you.


Comments