M
M
MagoVinch2016-06-23 16:52:52
Python
MagoVinch, 2016-06-23 16:52:52

How to get date and time from text in python?

let's say there are strings like "after tomorrow at 5:30", "next Tuesday after 3"
and from this you need to get the date based on the reference and time
. What are the patterns for solving this problem?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexey Cheremisin, 2016-06-23
@leahch

There is absolutely fuzzy logic here, most likely you will need to parse phrases into lexemes, then determine the grammar of the phrase itself. Moreover, "after tomorrow at 5:30" and "tomorrow after 5:30", although they differ by one letter, you can miss by a day :-)
and, for sure, it will not do without some kind of vector mathematics, such as what action follows what and what applies.
Well, at least you need a lot, a lot of test samples. For example "yesterday he said it would rain tomorrow, it didn't rain", "two days ago from the third Sunday in October".

A
Alexander Titov, 2016-06-23
@alex-t

Wow ... This is, in general, a serious analysis of the text, it is usually necessary not only to highlight the time from the text, but also to find what fact this mention of time refers to, you can do it on your own in a few years ... Our company just puts an expensive and quite loading the computer (C++ code) system that does it.
Well, if the input is already receiving only lines of time, then the task is foreseeable. In a few weeks of work, 90% of the lines will be determined, I think :)

M
Miguel De Cervantes, 2016-06-27
@migs911

there is ABBYY Compreno technology, which just specializes in text analysis. It has an API that returns a not-so-complicated XML in response.
https://www.abbyy.com/ru-ru/isearch/compreno/
You can ask them, you see, you don’t have to reinvent the wheel. It just might cost a fortune. But for the demand, they don’t take money)

V
Veniamin Belousov, 2016-06-23
@Venuhaha

Тык https://docs.python.org/3/library/datetime.html

Даниил Игоревич, 2016-06-23
@Petr_Anisimov

Парсите строку с помощью регулярок

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question