4

I have an NLP task which has 3 components. I tried few methods (mentioned in the end) but I am not able to get good results.

  1. Detecting temporal expressions in a statement
  2. Classifying then as either time stamp, time trigger or time period.
  3. Equate each expression to its DateTime equivalent.

Example:

Taking reference time as 2000 hrs, Thursday, July 20th, 2015

  1. time stamp :

    I want to book a cab 20 minutes from now

    Answer: [tStamp]2020 hrs, Thursday, July 20th
    
  2. time trigger :

    Any timer after 2 is fine

    Answer:  [tTrigger] - start - 0200 hrs,July 21st 2015
    

    Before 5 is good

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

    I was working in san francisco for last two years

    [tPeriod] -  2013-2015
    

I tried to do this with regex gives very generic results. Second option I read was to try to make the model learn from Naive Bays classifier but naive bays learns exact words and not phrases.

I came across parsedatetime 1.5 package in python which is awesome to some extent in converting phrases to timestamps which solves 3. of mentioned problem but still I am not able to solve detention and classification.

Rusty
  • 1,086
  • 2
  • 13
  • 27
  • 2
    This is not a code-writing service. Show your attempts and we will help. Please read [how to ask a question](http://stackoverflow.com/help/how-to-ask) – Pynchia Sep 26 '15 at 06:55
  • @pynchia: Sorry, if you got me wrong !!! I am new to NLP and so wanted a heads on. As of now, I know that regex won't work. I wanted to know which other tools I can use. Definitely I will write the code myself. That is why I tagged the question with NLP keywords not any language keywords. – Rusty Sep 26 '15 at 07:28
  • 1
    Naive Bayes doesn't learn words, it learns probabilities given some input and a former believe about the probability of discovering that input, given some context. That might be helpful if you start to think about the combination of words and their order. I'm not saying Naive Bayes is the way to go, just pointing out that it doesn't stop where you indicated it does. – miraculixx Sep 26 '15 at 10:38
  • @miraculixx thanks, let me give a shot. – Rusty Sep 26 '15 at 13:13
  • I'm interested in the same problem - did you discover how to best approach this problem? – tomburger May 23 '16 at 12:48
  • @tomburger : Not exactly but I am handling it through an exhaustive set of regular expressions. – Rusty May 24 '16 at 17:37

1 Answers1

3

There's a Python wrapper for Stanford's CoreNLP library, which includes the SUTime tool. Check out the online SUTime demo to see if this can be useful to you.

Yuval
  • 7,987
  • 12
  • 40
  • 54
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/13172615) – noɥʇʎԀʎzɐɹƆ Jul 30 '16 at 21:09
  • 1
    Out of curiousity, how would you show the demo in the answer? – Yuval Jul 31 '16 at 07:15
  • condense the tutorial, add some more explanation, etc. – noɥʇʎԀʎzɐɹƆ Jul 31 '16 at 17:21
  • 1
    In this case, this is an academic tool, written and maintained by the Stanford NLP lab. I think their explanations are concise and far better than any I could provide here. There's no tutorial per se, more of a usage section on the page that shows how to call the library. Can't think what I would add to these.. – Yuval Aug 01 '16 at 21:10
  • Perhaps... but I don't know a better free tool out there for this kind of job. – Yuval Aug 02 '16 at 11:30