Date Extraction in PythonMachine learning or NLP approach to convert string about month ,year into...

How to acknowledge an embarrassing job interview, now that I work directly with the interviewer?

Program that converts a number to a letter of the alphabet

I am on the US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

How do you funnel food off a cutting board?

Issues with new Macs: Hardware makes them difficult for me to use. What options might be available in the future?

When does coming up with an idea constitute sufficient contribution for authorship?

How experienced do I need to be to go on a photography workshop?

How would one buy a used TIE Fighter or X-Wing?

Why don't I see the difference between two different files in insert mode in vim?

QGIS: use geometry from different layer in symbology expression

Why is working on the same position for more than 15 years not a red flag?

Does 'rm -fr` remove the boot loader?

"On one hand" vs "on the one hand."

How to generate a matrix with certain conditions

Getting a UK passport renewed when you have dual nationality and a different name in your second country?

Are there any monsters that consume a player character?

Why do neural networks need so many training examples to perform?

The vanishing of sum of coefficients: symmetric polynomials

What is the purpose of easy combat scenarios that don't need resource expenditure?

How to avoid being sexist when trying to employ someone to function in a very sexist environment?

What is the time complexity of enqueue and dequeue of a queue implemented with a singly linked list?

Word or phrase for showing great skill at something without formal training in it

What's a good word to describe a public place that looks like it wouldn't be rough?

Is there hidden data in this .blend file? Trying to minimize the file size



Date Extraction in Python


Machine learning or NLP approach to convert string about month ,year into datesFeature extraction of images in PythonNeural networks: which cost function to use?Non-brute force approach to finding permissible English word anagramsImage feature extraction Python skimage blob_dogClustering Observations by String Sequences (Python/Pandas df)Convert Atypical Date Format for Time Series in PythonRelated words extraction in text processingWith the Start Date and End Date given , finding date counts in PandasUsing python and machine learning to extract information from an invoice? Inital dataset?Complex HTMLs Data Extraction with Python













4












$begingroup$


I would like to extract all date information from a given document. Essentially, I guess this can be done with a lot of regexes:




  • 2019-02-20

  • 20.02.2019 ("German format")

  • 02/2019 ("February 2019")

  • "tomorrow" (datetime.timedelta(days=1))

  • "yesterday" (datetime.timedelta(days=-1))


Is there a Python package / library which offers this already or do i have to write all of those regexes/logic myself?



I'm interested in Information Extraction from German and English texts. Mainly German, though.



Constraints



I don't have the complete dataset by now, but I have some idea about it:




  • 10 years of interesting dates which could be in the dataset

  • I guess the interesting date types are: (1) 28.02.2019, (2) relative ones like "3 days ago" (3) 28/02/2019, (4) 02/28/2019 (5) 2019-02-28 (6) 2019/02/28 (7) 2019/28/02 (8) 28.2.2019 (9) 28.2 (10) ... -- all of which could have spaces in various places

  • I have millions of documents. Every document has around 20 sentences, I guess.

  • Most of the data is in German










share|improve this question











$endgroup$












  • $begingroup$
    I had looked into this about 6 months ago and could not find anything that works out of the box for both English and German. What seemed promising was using some fuzzy matching, given you can make some half-descent assumptions about the possible formats, as in your examples. The same would go for a regex solution, I suppose. You could combine the approaches even.
    $endgroup$
    – n1k31t4
    Feb 20 at 9:54










  • $begingroup$
    fuzzywuzzy up to my knowledge is a bad match, as it essentially uses the Levensthein distance. For dates I need regexes ... Although I could list all reasonable dates (10 years = 3653 elements) and all formats I'm interested in (maybe 10), doing fuzzy matching for roughly 36'530 elements over millions of documents is not feasible.
    $endgroup$
    – Martin Thoma
    Feb 20 at 13:36










  • $begingroup$
    I agree it isn't optimal, but using heuristic parameters could work fairly well (it did for me). You could brute force it as you suggest - you hadn't mentioned millions of documents. Being more specific; it is really the number of tokens which is important (how big is a document?). Perhaps you could update your question to include those additional computation considerations/constraints.
    $endgroup$
    – n1k31t4
    Feb 20 at 14:13
















4












$begingroup$


I would like to extract all date information from a given document. Essentially, I guess this can be done with a lot of regexes:




  • 2019-02-20

  • 20.02.2019 ("German format")

  • 02/2019 ("February 2019")

  • "tomorrow" (datetime.timedelta(days=1))

  • "yesterday" (datetime.timedelta(days=-1))


Is there a Python package / library which offers this already or do i have to write all of those regexes/logic myself?



I'm interested in Information Extraction from German and English texts. Mainly German, though.



Constraints



I don't have the complete dataset by now, but I have some idea about it:




  • 10 years of interesting dates which could be in the dataset

  • I guess the interesting date types are: (1) 28.02.2019, (2) relative ones like "3 days ago" (3) 28/02/2019, (4) 02/28/2019 (5) 2019-02-28 (6) 2019/02/28 (7) 2019/28/02 (8) 28.2.2019 (9) 28.2 (10) ... -- all of which could have spaces in various places

  • I have millions of documents. Every document has around 20 sentences, I guess.

  • Most of the data is in German










share|improve this question











$endgroup$












  • $begingroup$
    I had looked into this about 6 months ago and could not find anything that works out of the box for both English and German. What seemed promising was using some fuzzy matching, given you can make some half-descent assumptions about the possible formats, as in your examples. The same would go for a regex solution, I suppose. You could combine the approaches even.
    $endgroup$
    – n1k31t4
    Feb 20 at 9:54










  • $begingroup$
    fuzzywuzzy up to my knowledge is a bad match, as it essentially uses the Levensthein distance. For dates I need regexes ... Although I could list all reasonable dates (10 years = 3653 elements) and all formats I'm interested in (maybe 10), doing fuzzy matching for roughly 36'530 elements over millions of documents is not feasible.
    $endgroup$
    – Martin Thoma
    Feb 20 at 13:36










  • $begingroup$
    I agree it isn't optimal, but using heuristic parameters could work fairly well (it did for me). You could brute force it as you suggest - you hadn't mentioned millions of documents. Being more specific; it is really the number of tokens which is important (how big is a document?). Perhaps you could update your question to include those additional computation considerations/constraints.
    $endgroup$
    – n1k31t4
    Feb 20 at 14:13














4












4








4


1



$begingroup$


I would like to extract all date information from a given document. Essentially, I guess this can be done with a lot of regexes:




  • 2019-02-20

  • 20.02.2019 ("German format")

  • 02/2019 ("February 2019")

  • "tomorrow" (datetime.timedelta(days=1))

  • "yesterday" (datetime.timedelta(days=-1))


Is there a Python package / library which offers this already or do i have to write all of those regexes/logic myself?



I'm interested in Information Extraction from German and English texts. Mainly German, though.



Constraints



I don't have the complete dataset by now, but I have some idea about it:




  • 10 years of interesting dates which could be in the dataset

  • I guess the interesting date types are: (1) 28.02.2019, (2) relative ones like "3 days ago" (3) 28/02/2019, (4) 02/28/2019 (5) 2019-02-28 (6) 2019/02/28 (7) 2019/28/02 (8) 28.2.2019 (9) 28.2 (10) ... -- all of which could have spaces in various places

  • I have millions of documents. Every document has around 20 sentences, I guess.

  • Most of the data is in German










share|improve this question











$endgroup$




I would like to extract all date information from a given document. Essentially, I guess this can be done with a lot of regexes:




  • 2019-02-20

  • 20.02.2019 ("German format")

  • 02/2019 ("February 2019")

  • "tomorrow" (datetime.timedelta(days=1))

  • "yesterday" (datetime.timedelta(days=-1))


Is there a Python package / library which offers this already or do i have to write all of those regexes/logic myself?



I'm interested in Information Extraction from German and English texts. Mainly German, though.



Constraints



I don't have the complete dataset by now, but I have some idea about it:




  • 10 years of interesting dates which could be in the dataset

  • I guess the interesting date types are: (1) 28.02.2019, (2) relative ones like "3 days ago" (3) 28/02/2019, (4) 02/28/2019 (5) 2019-02-28 (6) 2019/02/28 (7) 2019/28/02 (8) 28.2.2019 (9) 28.2 (10) ... -- all of which could have spaces in various places

  • I have millions of documents. Every document has around 20 sentences, I guess.

  • Most of the data is in German







python text-mining






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 21 at 8:56







Martin Thoma

















asked Feb 20 at 6:19









Martin ThomaMartin Thoma

6,2931353130




6,2931353130












  • $begingroup$
    I had looked into this about 6 months ago and could not find anything that works out of the box for both English and German. What seemed promising was using some fuzzy matching, given you can make some half-descent assumptions about the possible formats, as in your examples. The same would go for a regex solution, I suppose. You could combine the approaches even.
    $endgroup$
    – n1k31t4
    Feb 20 at 9:54










  • $begingroup$
    fuzzywuzzy up to my knowledge is a bad match, as it essentially uses the Levensthein distance. For dates I need regexes ... Although I could list all reasonable dates (10 years = 3653 elements) and all formats I'm interested in (maybe 10), doing fuzzy matching for roughly 36'530 elements over millions of documents is not feasible.
    $endgroup$
    – Martin Thoma
    Feb 20 at 13:36










  • $begingroup$
    I agree it isn't optimal, but using heuristic parameters could work fairly well (it did for me). You could brute force it as you suggest - you hadn't mentioned millions of documents. Being more specific; it is really the number of tokens which is important (how big is a document?). Perhaps you could update your question to include those additional computation considerations/constraints.
    $endgroup$
    – n1k31t4
    Feb 20 at 14:13


















  • $begingroup$
    I had looked into this about 6 months ago and could not find anything that works out of the box for both English and German. What seemed promising was using some fuzzy matching, given you can make some half-descent assumptions about the possible formats, as in your examples. The same would go for a regex solution, I suppose. You could combine the approaches even.
    $endgroup$
    – n1k31t4
    Feb 20 at 9:54










  • $begingroup$
    fuzzywuzzy up to my knowledge is a bad match, as it essentially uses the Levensthein distance. For dates I need regexes ... Although I could list all reasonable dates (10 years = 3653 elements) and all formats I'm interested in (maybe 10), doing fuzzy matching for roughly 36'530 elements over millions of documents is not feasible.
    $endgroup$
    – Martin Thoma
    Feb 20 at 13:36










  • $begingroup$
    I agree it isn't optimal, but using heuristic parameters could work fairly well (it did for me). You could brute force it as you suggest - you hadn't mentioned millions of documents. Being more specific; it is really the number of tokens which is important (how big is a document?). Perhaps you could update your question to include those additional computation considerations/constraints.
    $endgroup$
    – n1k31t4
    Feb 20 at 14:13
















$begingroup$
I had looked into this about 6 months ago and could not find anything that works out of the box for both English and German. What seemed promising was using some fuzzy matching, given you can make some half-descent assumptions about the possible formats, as in your examples. The same would go for a regex solution, I suppose. You could combine the approaches even.
$endgroup$
– n1k31t4
Feb 20 at 9:54




$begingroup$
I had looked into this about 6 months ago and could not find anything that works out of the box for both English and German. What seemed promising was using some fuzzy matching, given you can make some half-descent assumptions about the possible formats, as in your examples. The same would go for a regex solution, I suppose. You could combine the approaches even.
$endgroup$
– n1k31t4
Feb 20 at 9:54












$begingroup$
fuzzywuzzy up to my knowledge is a bad match, as it essentially uses the Levensthein distance. For dates I need regexes ... Although I could list all reasonable dates (10 years = 3653 elements) and all formats I'm interested in (maybe 10), doing fuzzy matching for roughly 36'530 elements over millions of documents is not feasible.
$endgroup$
– Martin Thoma
Feb 20 at 13:36




$begingroup$
fuzzywuzzy up to my knowledge is a bad match, as it essentially uses the Levensthein distance. For dates I need regexes ... Although I could list all reasonable dates (10 years = 3653 elements) and all formats I'm interested in (maybe 10), doing fuzzy matching for roughly 36'530 elements over millions of documents is not feasible.
$endgroup$
– Martin Thoma
Feb 20 at 13:36












$begingroup$
I agree it isn't optimal, but using heuristic parameters could work fairly well (it did for me). You could brute force it as you suggest - you hadn't mentioned millions of documents. Being more specific; it is really the number of tokens which is important (how big is a document?). Perhaps you could update your question to include those additional computation considerations/constraints.
$endgroup$
– n1k31t4
Feb 20 at 14:13




$begingroup$
I agree it isn't optimal, but using heuristic parameters could work fairly well (it did for me). You could brute force it as you suggest - you hadn't mentioned millions of documents. Being more specific; it is really the number of tokens which is important (how big is a document?). Perhaps you could update your question to include those additional computation considerations/constraints.
$endgroup$
– n1k31t4
Feb 20 at 14:13










2 Answers
2






active

oldest

votes


















5












$begingroup$

Stanford CoreNLP has a very good implementation of NER for date/time.



https://nlp.stanford.edu/software/sutime.html (demo: http://nlp.stanford.edu:8080/sutime/process)



enter image description here



Though this is written in Java, there are quite a few Python wrappers for this library (Such as : https://github.com/FraBle/python-sutime). List of such libraries : https://stanfordnlp.github.io/CoreNLP/other-languages.html






share|improve this answer









$endgroup$













  • $begingroup$
    At least the web interface only offers English.
    $endgroup$
    – Martin Thoma
    Feb 20 at 7:21










  • $begingroup$
    These Languages are built-in : github.com/stanfordnlp/CoreNLP/tree/master/src/edu/stanford/nlp/… . You can look for German rules (if someone has created it) OR estimate work required for writing these based on number of rules in other language files.
    $endgroup$
    – Shamit Verma
    Feb 20 at 8:32



















0












$begingroup$

Spacy (https://spacy.io) comes with both English and German language model.



According to the documentation, it's NER works for both absolute as well as the relative date. https://spacy.io/usage/linguistic-features#section-named-entities





share









$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%2f45854%2fdate-extraction-in-python%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









    5












    $begingroup$

    Stanford CoreNLP has a very good implementation of NER for date/time.



    https://nlp.stanford.edu/software/sutime.html (demo: http://nlp.stanford.edu:8080/sutime/process)



    enter image description here



    Though this is written in Java, there are quite a few Python wrappers for this library (Such as : https://github.com/FraBle/python-sutime). List of such libraries : https://stanfordnlp.github.io/CoreNLP/other-languages.html






    share|improve this answer









    $endgroup$













    • $begingroup$
      At least the web interface only offers English.
      $endgroup$
      – Martin Thoma
      Feb 20 at 7:21










    • $begingroup$
      These Languages are built-in : github.com/stanfordnlp/CoreNLP/tree/master/src/edu/stanford/nlp/… . You can look for German rules (if someone has created it) OR estimate work required for writing these based on number of rules in other language files.
      $endgroup$
      – Shamit Verma
      Feb 20 at 8:32
















    5












    $begingroup$

    Stanford CoreNLP has a very good implementation of NER for date/time.



    https://nlp.stanford.edu/software/sutime.html (demo: http://nlp.stanford.edu:8080/sutime/process)



    enter image description here



    Though this is written in Java, there are quite a few Python wrappers for this library (Such as : https://github.com/FraBle/python-sutime). List of such libraries : https://stanfordnlp.github.io/CoreNLP/other-languages.html






    share|improve this answer









    $endgroup$













    • $begingroup$
      At least the web interface only offers English.
      $endgroup$
      – Martin Thoma
      Feb 20 at 7:21










    • $begingroup$
      These Languages are built-in : github.com/stanfordnlp/CoreNLP/tree/master/src/edu/stanford/nlp/… . You can look for German rules (if someone has created it) OR estimate work required for writing these based on number of rules in other language files.
      $endgroup$
      – Shamit Verma
      Feb 20 at 8:32














    5












    5








    5





    $begingroup$

    Stanford CoreNLP has a very good implementation of NER for date/time.



    https://nlp.stanford.edu/software/sutime.html (demo: http://nlp.stanford.edu:8080/sutime/process)



    enter image description here



    Though this is written in Java, there are quite a few Python wrappers for this library (Such as : https://github.com/FraBle/python-sutime). List of such libraries : https://stanfordnlp.github.io/CoreNLP/other-languages.html






    share|improve this answer









    $endgroup$



    Stanford CoreNLP has a very good implementation of NER for date/time.



    https://nlp.stanford.edu/software/sutime.html (demo: http://nlp.stanford.edu:8080/sutime/process)



    enter image description here



    Though this is written in Java, there are quite a few Python wrappers for this library (Such as : https://github.com/FraBle/python-sutime). List of such libraries : https://stanfordnlp.github.io/CoreNLP/other-languages.html







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 20 at 6:27









    Shamit VermaShamit Verma

    65026




    65026












    • $begingroup$
      At least the web interface only offers English.
      $endgroup$
      – Martin Thoma
      Feb 20 at 7:21










    • $begingroup$
      These Languages are built-in : github.com/stanfordnlp/CoreNLP/tree/master/src/edu/stanford/nlp/… . You can look for German rules (if someone has created it) OR estimate work required for writing these based on number of rules in other language files.
      $endgroup$
      – Shamit Verma
      Feb 20 at 8:32


















    • $begingroup$
      At least the web interface only offers English.
      $endgroup$
      – Martin Thoma
      Feb 20 at 7:21










    • $begingroup$
      These Languages are built-in : github.com/stanfordnlp/CoreNLP/tree/master/src/edu/stanford/nlp/… . You can look for German rules (if someone has created it) OR estimate work required for writing these based on number of rules in other language files.
      $endgroup$
      – Shamit Verma
      Feb 20 at 8:32
















    $begingroup$
    At least the web interface only offers English.
    $endgroup$
    – Martin Thoma
    Feb 20 at 7:21




    $begingroup$
    At least the web interface only offers English.
    $endgroup$
    – Martin Thoma
    Feb 20 at 7:21












    $begingroup$
    These Languages are built-in : github.com/stanfordnlp/CoreNLP/tree/master/src/edu/stanford/nlp/… . You can look for German rules (if someone has created it) OR estimate work required for writing these based on number of rules in other language files.
    $endgroup$
    – Shamit Verma
    Feb 20 at 8:32




    $begingroup$
    These Languages are built-in : github.com/stanfordnlp/CoreNLP/tree/master/src/edu/stanford/nlp/… . You can look for German rules (if someone has created it) OR estimate work required for writing these based on number of rules in other language files.
    $endgroup$
    – Shamit Verma
    Feb 20 at 8:32











    0












    $begingroup$

    Spacy (https://spacy.io) comes with both English and German language model.



    According to the documentation, it's NER works for both absolute as well as the relative date. https://spacy.io/usage/linguistic-features#section-named-entities





    share









    $endgroup$


















      0












      $begingroup$

      Spacy (https://spacy.io) comes with both English and German language model.



      According to the documentation, it's NER works for both absolute as well as the relative date. https://spacy.io/usage/linguistic-features#section-named-entities





      share









      $endgroup$
















        0












        0








        0





        $begingroup$

        Spacy (https://spacy.io) comes with both English and German language model.



        According to the documentation, it's NER works for both absolute as well as the relative date. https://spacy.io/usage/linguistic-features#section-named-entities





        share









        $endgroup$



        Spacy (https://spacy.io) comes with both English and German language model.



        According to the documentation, it's NER works for both absolute as well as the relative date. https://spacy.io/usage/linguistic-features#section-named-entities






        share











        share


        share










        answered 8 mins ago









        Louis TLouis T

        746320




        746320






























            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%2f45854%2fdate-extraction-in-python%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

            is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

            How do i solve the “ No module named 'mlxtend' ” issue on Jupyter?

            Pilgersdorf Inhaltsverzeichnis Geografie | Geschichte | Bevölkerungsentwicklung | Politik | Kultur...