Skip to content

poyo46/jatime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jatime: Time Expression Analyzer for Japanese

PyPI Version Python Versions License Code style: black Imports: isort Test Status

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!

Installing jatime

Install with pip or your favorite PyPI package manager.

$ pip install jatime

Using 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 "http://localhost:1729/analysis" --data-urlencode "string=それは令和2年十月十七日の出来事でした。"
["それは",{"day":17,"dow":5,"hour":null,"minute":null,"month":10,"string":"令和2年十月十七日","year":2020},"の出来事でした。"]

Features

  • 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, 午後十時半 and P.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.