Machine learning or NLP approach to convert string about month ,year into dates












3












$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!










share|improve this question









$endgroup$








  • 1




    $begingroup$
    See : datascience.stackexchange.com/questions/45854/…
    $endgroup$
    – Shamit Verma
    yesterday
















3












$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!










share|improve this question









$endgroup$








  • 1




    $begingroup$
    See : datascience.stackexchange.com/questions/45854/…
    $endgroup$
    – Shamit Verma
    yesterday














3












3








3


2



$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!










share|improve this question









$endgroup$




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!







machine-learning python nlp nltk regex






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









bipul kumarbipul kumar

213




213








  • 1




    $begingroup$
    See : datascience.stackexchange.com/questions/45854/…
    $endgroup$
    – Shamit Verma
    yesterday














  • 1




    $begingroup$
    See : datascience.stackexchange.com/questions/45854/…
    $endgroup$
    – Shamit Verma
    yesterday








1




1




$begingroup$
See : datascience.stackexchange.com/questions/45854/…
$endgroup$
– Shamit Verma
yesterday




$begingroup$
See : datascience.stackexchange.com/questions/45854/…
$endgroup$
– Shamit Verma
yesterday










2 Answers
2






active

oldest

votes


















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






share|improve this answer









$endgroup$













  • $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 kumar
    13 hours ago





















0












$begingroup$

Sounds like you need a temporal tagger. This is a good rule-based one https://github.com/HeidelTime/heideltime



Stanford CoreNLP also has one https://nlp.stanford.edu/software/sutime.html



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






share|improve this answer








New contributor




Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "557"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f45856%2fmachine-learning-or-nlp-approach-to-convert-string-about-month-year-into-dates%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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






    share|improve this answer









    $endgroup$













    • $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 kumar
      13 hours ago


















    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






    share|improve this answer









    $endgroup$













    • $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 kumar
      13 hours ago
















    0












    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






    share|improve this answer









    $endgroup$



    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







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered yesterday









    TasosTasos

    955530




    955530












    • $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 kumar
      13 hours ago




















    • $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 kumar
      13 hours ago


















    $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 kumar
    13 hours ago






    $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 kumar
    13 hours ago













    0












    $begingroup$

    Sounds like you need a temporal tagger. This is a good rule-based one https://github.com/HeidelTime/heideltime



    Stanford CoreNLP also has one https://nlp.stanford.edu/software/sutime.html



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






    share|improve this answer








    New contributor




    Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






    $endgroup$


















      0












      $begingroup$

      Sounds like you need a temporal tagger. This is a good rule-based one https://github.com/HeidelTime/heideltime



      Stanford CoreNLP also has one https://nlp.stanford.edu/software/sutime.html



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






      share|improve this answer








      New contributor




      Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      $endgroup$
















        0












        0








        0





        $begingroup$

        Sounds like you need a temporal tagger. This is a good rule-based one https://github.com/HeidelTime/heideltime



        Stanford CoreNLP also has one https://nlp.stanford.edu/software/sutime.html



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






        share|improve this answer








        New contributor




        Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        $endgroup$



        Sounds like you need a temporal tagger. This is a good rule-based one https://github.com/HeidelTime/heideltime



        Stanford CoreNLP also has one https://nlp.stanford.edu/software/sutime.html



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







        share|improve this answer








        New contributor




        Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered yesterday









        Igor BrigadirIgor Brigadir

        262




        262




        New contributor




        Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Igor Brigadir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Data Science Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f45856%2fmachine-learning-or-nlp-approach-to-convert-string-about-month-year-into-dates%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Callistus I

            Tabula Rosettana

            How to label and detect the document text images