5
$\begingroup$

I'm currently in the process of developing a program with the capability of converting human style of representing year into actual dates. Example : last year last month into December 2018 string may be complete sentence like : what were you doing 5 years ago

it will gives 2014

The purpose is to evalute human style of represting year or date into actual date, i have created collection of this type of strings and matching them with regex.

I have read some machine learning but I'm not sure which algorithm suits this problem the best or if I should consider using NLP.

Does anyone have a suggestion of what algorithm to use or where I can find the necessary literature to solve my problem?

Thanks for any contribution!

$\endgroup$
2

3 Answers 3

2
$\begingroup$

I got my answer , NLTK is good to go for this problem. You may use sutime with python wrapper :

Python wrapper for Stanford CoreNLP's SUTime

The usual approach in NLP is to collect a dataset required for training. Process that dataset so that the words in the dataset are converted into numbers.

One simple example of converting it into numbers is to make a large dictionary of words from the dataset and use the index of each word in the dictionary as the representing number

$\endgroup$
0
0
$\begingroup$

What you need to look for is called "Named Entity recognition". From Wikipedia

Named-entity recognition (NER) (also known as entity identification, entity chunking and entity extraction) is a subtask of information extraction that seeks to locate and classify named entity mentions in unstructured text into pre-defined categories such as the person names, organizations, locations, medical codes, time expressions, quantities, monetary values, percentages, etc.

As it is mentioned in the comments section, Stanford has a great NER Tagger and you could use that together with Python (even if the StanfordNLP is implemented in Java)

Download the jar file from the official url. It has this format stanford-ner-xxxx-xx-xx.zip

You need to put the following two files in the same application folder as your Python script

  1. ner-tagger.jar
  2. ner-model-english.ser.gz (choose another one if you don't want English)

import nltk

from nltk.tag.stanford import StanfordNERTagger  

yourText = this_is_your_text

words = nltk.word_tokenize(yourText)
jar = './stanford-ner.jar'
model = './ner-model-english.ser.gz'

tagger = StanfordNERTagger(model, jar, encoding='utf8')

print(ner_tagger.tag(words))

Then you can grab from the above, anything that is tagged as DATE

$\endgroup$
1
  • $\begingroup$ ner-model-english.ser.gz is not present in that zip and i am trying to use other file from classifier (english.all.3class.distsim.crf.ser.gz) but i always stuck with following error: TypeError: Can't instantiate abstract class StanfordTagger with abstract methods _cmd $\endgroup$
    – Bipul
    Commented Feb 21, 2019 at 7:46
0
$\begingroup$

Sounds like you need a temporal tagger. This is a good rule-based one.

Stanford CoreNLP also has one.

It seems like generally rule-based approaches work well for this task.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.