Jatime is a Python library to extract Japanese time expressions from a given text and turning them into objects. Try jatime now from your browser!
Install with pip
or your favorite PyPI package manager.
$ pip install jatime
Here's how to analyze Japanese text using jatime. Note that "dow" means the day of the week.
From within Python
from jatime.analyzer import analyze
result = analyze("それは令和2年十月十七日の出来事でした。")
print(result)
['それは', {'string': '令和2年十月十七日', 'year': 2020, 'month': 10, 'day': 17, 'dow': 5, 'hour': None, 'minute': None}, 'の出来事でした。']
From the command line
$ jatime analyze --format-json それは令和2年十月十七日の出来事でした。
[
"それは",
{
"string": "令和2年十月十七日",
"year": 2020,
"month": 10,
"day": 17,
"dow": 5,
"hour": null,
"minute": null
},
"の出来事でした。"
]
Over HTTP communication
$ jatime serve
$ curl --get "https://localhost:1729/analysis" --data-urlencode "string=それは令和2年十月十七日の出来事でした。"
["それは",{"day":17,"dow":5,"hour":null,"minute":null,"month":10,"string":"令和2年十月十七日","year":2020},"の出来事でした。"]
- Jatime does not change the given string at all. It just objectifies the extracted time expressions.
- Jatime supports a variety of time expressions. For example,
22:30
,午後十時半
andP.M.10:30
are all interpreted as the same time as we want. - Jatime tries to make up for the missing time information whenever possible. That is, jatime calculates the year given the month, day and day of the week.
- Jatime will tell us why the time information is inconsistent if it is inconsistent.