Original link: https://www.kingname.info/2022/07/13/nlp-datetime/
If you’ve used Tick List or Todoist, you should know that they have a very useful feature, which is to automatically recognize the time in tasks, such as:
1 |
Email the boss next Tuesday at 3pm |
It is automatically recognized as:
Today, in the official account fan group, a classmate named NowAnti recommended a project called Sinan , which can make Python realize such a function.
Let’s take a look at how this third-party library is used. First pip install it:
1 |
python3 -m pip install sinan |
After the installation is complete, the usage method is very simple:
1 |
from sinan import Sinan |
The operation effect is shown in the following figure:
Not only can this library parse time, it can also parse more complex statements such as:
1 |
>>> obj = Sinan( 'Pick up 10 kilograms of gifts at 8 o'clock tomorrow night, walk 2 kilometers west, wait in place for 3 hours, if the temperature is lower than 16 degrees, call me, my cell phone No. is: 16758493028' ) |
The operation effect is shown in the following figure:
This article is reprinted from: https://www.kingname.info/2022/07/13/nlp-datetime/
This site is for inclusion only, and the copyright belongs to the original author.