自然言語で書かれた時間情報表現を抽出/規格化するルールベースの解析器

Overview

ja-timex

自然言語で書かれた時間情報表現を抽出/規格化するルールベースの解析器

概要

ja-timex は、現代日本語で書かれた自然文に含まれる時間情報表現を抽出しTIMEX3と呼ばれるアノテーション仕様に変換することで、プログラムが利用できるような形に規格化するルールベースの解析器です。

以下の機能を持っています。

  • ルールベースによる日本語テキストからの日付や時刻、期間や頻度といった時間情報表現を抽出
  • アラビア数字/漢数字、西暦/和暦などの多彩なフォーマットに対応
  • 時間表現のdatetime/timedelta形式への変換サポート

入力

from ja_timex import TimexParser

timexes = TimexParser().parse("彼は2008年4月から週に3回ジョギングを1時間行ってきた")

出力

[<TIMEX3 tid="t0" type="DATE" value="2008-04-XX" text="2008年4月">,
 <TIMEX3 tid="t1" type="SET" value="P1W" freq="3X" text="週に3回">,
 <TIMEX3 tid="t2" type="DURATION" value="PT1H" text="1時間">]

datetime/timedeltaへの変換

# <TIMEX3 tid="t0" type="DATE" value="2008-04-XX" text="2008年4月">
In []: timexes[0].to_datetime()
Out[]: DateTime(2008, 4, 1, 0, 0, 0, tzinfo=Timezone('Asia/Tokyo'))
# <TIMEX3 tid="t2" type="DURATION" value="PT1H" text="1時間">
In []: timexes[2].to_duration()
Out[]: Duration(hours=1)

インストール

pip install ja-timex

ドキュメント

ja-timex documentation

参考仕様

本パッケージは、以下の論文で提案されている時間情報アノテーションの枠組みを元に作成しています。

Comments
  • [Feature Request] 漢数字からアラビア数字への変換を無効にするオプションの追加

    [Feature Request] 漢数字からアラビア数字への変換を無効にするオプションの追加

    🚀 機能提案

    漢数字からアラビア数字への変換を無効にするオプションの追加

    モチベーション

    • 漢数字からアラビア数字に変換する際に「一時はどうなることかと」「十分なインターバル」といった表現を誤検出してしまう問題がある
    • 日付が漢数字で書かれないドキュメントであることが分かっている場合には、こうした変換を無効にすることで抽出精度を上げることができる

    解決策や課題解決の方針

    以下のように引数を渡す。

    timex_parser = TimexParser(ignroe_kansuji=True)
    

    追加/補足情報

    enhancement 
    opened by yagays 3
  • [Modify Rules] 夜9時・今夜9時のような表現のサポート

    [Modify Rules] 夜9時・今夜9時のような表現のサポート

    📝 時間情報表現のルール

    今夜9時今日の夜9時からのような表現を21時として解釈する

    用例

    告知などでよく使われる表現。 https://twitter.com/telebee_tnc/status/1420572285157613574

    時間表現への変換

    >>> timexes = TimexParser().parse("今夜9時スタートです。")
    >>> timexes
    [<TIMEX3 tid="t0" type="TIME" value="T21-XX-XX" text="夜9時">]
    

    早速使わせていただいています。是非ご検討のほどお願いします。

    opened by harokki 3
  • [Bug] 日付表現で半を含む際のto_datetime()の動作

    [Bug] 日付表現で半を含む際のto_datetime()の動作

    🐛 Bug

    説明

    日付表現に半や午後(PM)を含むとき、to_datetime()を実行すると、TIMEX3タグのvalueには反映されているようですが、日付型/時間型に半や午後の時刻が反映されません。 仕様でしょうか?? 初issueなので何か間違えていたら申し訳ありません。よろしくお願いします。

    現状挙動

    timex_parser = TimexParser(reference=pendulum.now()) # 2022/8/27 18:00:00 
    print(timex_parser.parse("20時半"))
    print(timex_parser.parse("20時半")[0].to_datetime())
    print()
    print(timex_parser.parse("午後11時"))
    print(timex_parser.parse("午後11時")[0].to_datetime())
    

    出力

    [<TIMEX3 tid="t0" type="TIME" value="T20-30-XX" text="20時半">]
    2022-08-27T20:00:00+09:00
    
    [<TIMEX3 tid="t0" type="TIME" value="T23-XX-XX" text="午後11時">]
    2022-08-27T11:00:00+09:00
    

    理想の挙動

    出力

    [<TIMEX3 tid="t0" type="TIME" value="T20-30-XX" text="20時半">]
    2022-08-27T20:30:00+09:00
    
    [<TIMEX3 tid="t0" type="TIME" value="T23-XX-XX" text="午後11時">]
    2022-08-27T23:00:00+09:00
    

    実行環境

    • ja-timexのバージョン : 0.2.6
    • Pythonのバージョン : 3.10.5
    • OSの情報: Windows10
    bug 
    opened by qwertyroiro 2
  • [Bug] 漢数字の時刻表現のspanがずれる

    [Bug] 漢数字の時刻表現のspanがずれる

    🐛 Bug

    説明

    入力した文章から抽出したtimexがもっているspanの長さが想定していた長さとちがう。

    現状挙動

    text = "平成三十一年に起きた出来事はなんですか?"
    timex = TimexParser().parse(text)
    print(timex[0].span)
    # (0,5)
    

    理想の挙動

    text = "平成三十一年に起きた出来事はなんですか?"
    timex = TimexParser().parse(text)
    print(timex[0].span)
    # (0,6)
    

    再現方法やエラー内容

    実行環境

    • ja-timexのバージョン : 0.2.0
    • Pythonのバージョン : 3.8.10
    • OSの情報: MacOS Bigsur

    追加/補足情報

    もしかしてbugではなく、一度漢数字をアラビア数字にしたあと、spanをとっているのでしょうか?そういう仕様なのでしょうか? もしそうでしたら、変更前の文字列のspan情報が欲しいというfeatureを投げたいです。

    bug 
    opened by reonyanarticle 2
  • [Feature Request] 期間を含む表現が数字を含まない場合にも range_start (range_end) が取得できる

    [Feature Request] 期間を含む表現が数字を含まない場合にも range_start (range_end) が取得できる

    🚀 機能提案

    現在 TimexParser.parse は期間を表す表現(例えば「15日から16日」)のときには、range_startrange_end) がTrueとなります。一方数字を含まない表現「昨日から今日」の場合には range_start は機能していません。

    スクリーンショット 2022-01-31 10 44 51

    そこで数字を含まない期間表現が入力に含まれている場合にも range_start (end) が True となる挙動になってほしいと考えています 🙏

    モチベーション

    • 本パッケージのユーザが期間表現が数字を含まない場合に特殊なフローを追加しなくても良くなる。

    解決策や課題解決の方針

    追加/補足情報

    enhancement 
    opened by takahi-i 1
  • [Modify Rules] 複数の日付間の範囲指定のrangeStartとrangeEndが対応しない

    [Modify Rules] 複数の日付間の範囲指定のrangeStartとrangeEndが対応しない

    📝 時間情報表現のルール

    「2012年5月30日(水)〜6月10日(日)」といった表現の際に、中間の2つに対してrangeStartとrangeEndが付与され、外側の2つには付与されない。

    [<TIMEX3 tid="t0" type="DATE" value="2012-05-30" text="2012年5月30日">,
     <TIMEX3 tid="t1" type="DATE" value="XXXX-WXX-3" range_start="True" text="(水)">,
     <TIMEX3 tid="t2" type="DATE" value="XXXX-06-10" range_end="True" text="6月10日">,
     <TIMEX3 tid="t3" type="DATE" value="XXXX-WXX-7" text="(日)">]
    

    用例

    「2012年5月30日(水)〜6月10日(日)」

    時間表現への変換

    仕様を検討

    追加/補足情報

    rule 
    opened by yagays 1
Releases(v0.2.7)
  • v0.2.7(Sep 14, 2022)

  • v0.2.6(Jun 11, 2022)

  • v0.2.5(Apr 17, 2022)

    Changes

    🐛 Bug Fixes

    • 文字列正規化により文字列長が長くなる場合にspanが補正されない問題を修正 (#82) @yagays

    📖 Documentation and examples

    • ドキュメントを更新 (#81) @yagays
    • update docs (#78) @yagays
    • ドキュメントを更新 (#77) @yagays

    🚧 Maintenance

    • release-drafterが対象とするデフォルトブランチ名を変更 (#80) @yagays
    • ブランチ名がfeatureかfixの場合のみCIでtoxを実行 (#79) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.2.4(Feb 23, 2022)

  • v0.2.3(Feb 4, 2022)

    Changes

    🚀 Features

    • 今世紀という表現をサポート (#74) @yagays
    • 範囲表現でも期間を表す場合に対応 (#73) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Jan 29, 2022)

    Changes

    🐛 Bug Fixes

    • 漢数字やコンマなどの正規化前の時刻表現の文字列とスパンをTIMEXタグに含める (#70) @yagays

    📖 Documentation and examples

    • ドキュメントに時刻表現の数値の正規化の追加 (#71) @yagays

    🚧 Maintenance

    • dev-dependenciesのバージョンを一括で上げる (#69) @yagays
    • 現在の年を補完するテストを修正 (#68) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Oct 17, 2021)

    Changes

    🚀 Features

    • Xから翌Yという表現を範囲表現として取得する (#65) @yagays
    • 12:00〜17:30といった時間表現の抽出ミスを修正 (#64) @yagays

    🐛 Bug Fixes

    • 年表記で数字が小さいときもDATEとして抽出される問題を修正 (#66) @yagays

    📖 Documentation and examples

    • ドキュメントを修正 (#59) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Sep 5, 2021)

    Changes

    TIMEXクラスに、範囲表現と起点と終点を表すrange_startrange_endというクラス変数を追加しました。

    🚀 Features

    • TIMEXタグの__repr__にrangeStart, rangeEndを追加 (#57) @yagays
    • "1,2ヶ月"や"1~2分"といった複数の日付表現が列挙された場合に対応 (#56) @yagays
    • TIMEXタグのrangeStartとrangeEndを追加し、抽出ルールを実装 (#55) @yagays

    📖 Documentation and examples

    • rangeStartとrangeEndに対応 (#58) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.1.9(Aug 29, 2021)

    Changes

    🚀 Features

    • 数字正規化済みのテキストを利用できるように変更 (#52) @yagays

    🐛 Bug Fixes

    • 複数の漢数字を処理できない問題を修正 (#53) @yagays

    📖 Documentation and examples

    • ユーザが独自にルールを指定できるCustomTaggerのテストとドキュメントを追加 (#54) @yagays

    🚧 Maintenance

    • ユーザが独自にルールを指定できるCustomTaggerのテストとドキュメントを追加 (#54) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.1.8(Aug 22, 2021)

    Changes

    🚀 Features

    • Filterの導入により対象外の表現を除外 (#49) @yagays

    🐛 Bug Fixes

    • 0.5ヶ月や3.5年前といった表現の取得ミスを修正 (#50) @yagays
    • 数字の途中を日付と誤認識する問題を修正 (#48) @yagays

    📖 Documentation and examples

    • 抽出例の具体例および既存研究との差異を追加 (#47) @yagays

    🚧 Maintenance

    • stop poetry install before running tox (#51) @yagays
    • Fix typos (#46) @shirayu
    Source code(tar.gz)
    Source code(zip)
  • v0.1.7(Aug 14, 2021)

    Changes

    🚀 Features

    • 漢数字を変換しないignore_kansujiパラメータを追加 (#44) @yagays
    • 末日という表現をサポート (#42) @yagays
    • 16世紀頃, 紀元前2世紀近くといった表現をサポート (#40) @yagays
    • 早朝6時や10時半といった表現をサポート (#36) @yagays
    • 深夜0時や深夜25時といった表現をサポート (#35) @yagays
    • 3日ぶりや10年ぶりといった表現をサポート (#32) @yagays
    • 8日目や30年もの間といった表現をサポート (#30) @yagays

    🐛 Bug Fixes

    • 一時代を時間として取得してしまう問題を修正 (#45) @yagays
    • 翌週28日が週28日と取得される問題を修正 (#39) @yagays
    • remove JUST mod (#38) @yagays
    • 数字が複数含まれるときに桁数のコンマ処理がされない問題を修正 (#37) @yagays
    • 12:30といった全角コロンの時間表記を取得できるように修正 (#34) @yagays
    • 時刻表現の後にスペースがある際にTimex.textに含まれないように修正 (#33) @yagays
    • 東京・千代田区や千春,千夏,千秋,千冬といった表現を取得してしまうバグを修正 (#31) @yagays
    • 全角括弧の囲みを取得するように修正 (#29) @yagays

    📖 Documentation and examples

    • update docs (#41) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.1.6(Aug 9, 2021)

    Changes

    🚀 Features

    • to_datetime()でデフォルトのtimezoneを設定可能にする (#27) @yagays
    • 1年半後や1時間半前、半年といった表現をサポート (#23) @yagays
    • "半"という表現をサポート (#22) @yagays

    🐛 Bug Fixes

    • 先月や半年前などの数字を伴わない表現でto_duration()の計算を修正 (#25) @yagays
    • "世紀"の前に数字が無いとエラーが出る問題を修正 (#24) @yagays

    📖 Documentation and examples

    • 日付型/時間型への変換方法の説明を追加 (#28) @yagays
    • typoを修正 (#18) @yagays

    🚧 Maintenance

    • テストを追加 (#26) @yagays
    • enable to trigger with release drafter (#17) @yagays
    Source code(tar.gz)
    Source code(zip)
  • v0.1.5(Aug 6, 2021)

    Changes

    🚀 Features

    • 基準日を設定できるようにする (#14) @yagays
    • 夜9時・今夜9時のような表現をサポート (#13) @yagays (thanks @harokki)

    📖 Documentation and examples

    • 基準日時の説明を追加 (#16) @yagays

    🚧 Maintenance

    • streamlitのアプリでto_datetime/to_durationに対応 (#15) @yagays
    • add release-drafter (#12) @yagays
    Source code(tar.gz)
    Source code(zip)
  • 0.1.4(Aug 5, 2021)

    🐛 Bug fixes

    • "毎年6月"が"年6月"と判定されるバグを修正 #4
    • Windows環境でテストが通らないエラーを修正 #8

    🚧 Maintenance

    • CIを整備 #6 #10
    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Aug 1, 2021)

  • 0.1.0(Aug 1, 2021)

Owner
Yuki Okuda
Yuki Okuda
Tensorflow Implementation of A Generative Flow for Text-to-Speech via Monotonic Alignment Search

Tensorflow Implementation of A Generative Flow for Text-to-Speech via Monotonic Alignment Search

Ankur Dhuriya 10 Oct 13, 2022
End-2-end speech synthesis with recurrent neural networks

Introduction New: Interactive demo using Google Colaboratory can be found here TTS-Cube is an end-2-end speech synthesis system that provides a full p

Tiberiu Boros 214 Dec 07, 2022
Auto translate textbox from Japanese to English or Indonesia

priconne-auto-translate Auto translate textbox from Japanese to English or Indonesia How to use Install python first, Anaconda is recommended Install

Aji Priyo Wibowo 5 Aug 25, 2022
iSTFTNet : Fast and Lightweight Mel-spectrogram Vocoder Incorporating Inverse Short-time Fourier Transform

iSTFTNet : Fast and Lightweight Mel-spectrogram Vocoder Incorporating Inverse Short-time Fourier Transform This repo try to implement iSTFTNet : Fast

Rishikesh (ऋषिकेश) 126 Jan 02, 2023
A fast Text-to-Speech (TTS) model. Work well for English, Mandarin/Chinese, Japanese, Korean, Russian and Tibetan (so far). 快速语音合成模型,适用于英语、普通话/中文、日语、韩语、俄语和藏语(当前已测试)。

简体中文 | English 并行语音合成 [TOC] 新进展 2021/04/20 合并 wavegan 分支到 main 主分支,删除 wavegan 分支! 2021/04/13 创建 encoder 分支用于开发语音风格迁移模块! 2021/04/13 softdtw 分支 支持使用 Sof

Atomicoo 161 Dec 19, 2022
Count the frequency of letters or words in a text file and show a graph.

Word Counter By EBUS Coding Club Count the frequency of letters or words in a text file and show a graph. Requirements Python 3.9 or higher matplotlib

EBUS Coding Club 0 Apr 09, 2022
JaQuAD: Japanese Question Answering Dataset

JaQuAD: Japanese Question Answering Dataset for Machine Reading Comprehension (2022, Skelter Labs)

SkelterLabs 84 Dec 27, 2022
Main repository for the chatbot Bobotinho.

Bobotinho Bot Main repository for the chatbot Bobotinho. ℹ️ Introduction Twitch chatbot with entertainment commands. ‎ 💻 Technologies Concurrent code

Bobotinho 14 Nov 29, 2022
Disfl-QA: A Benchmark Dataset for Understanding Disfluencies in Question Answering

Disfl-QA is a targeted dataset for contextual disfluencies in an information seeking setting, namely question answering over Wikipedia passages. Disfl-QA builds upon the SQuAD-v2 (Rajpurkar et al., 2

Google Research Datasets 52 Jun 21, 2022
Sequence model architectures from scratch in PyTorch

This repository implements a variety of sequence model architectures from scratch in PyTorch. Effort has been put to make the code well structured so that it can serve as learning material. The train

Brando Koch 11 Mar 28, 2022
Question answering app is used to answer for a user given question from user given text.

Question answering app is used to answer for a user given question from user given text.It is created using HuggingFace's transformer pipeline and streamlit python packages.

Siva Prakash 3 Apr 05, 2022
My Implementation for the paper EDA: Easy Data Augmentation Techniques for Boosting Performance on Text Classification Tasks using Tensorflow

Easy Data Augmentation Implementation This repository contains my Implementation for the paper EDA: Easy Data Augmentation Techniques for Boosting Per

Aflah 9 Oct 31, 2022
Binary LSTM model for text classification

Text Classification The purpose of this repository is to create a neural network model of NLP with deep learning for binary classification of texts re

Nikita Elenberger 1 Mar 11, 2022
Guide to using pre-trained large language models of source code

Large Models of Source Code I occasionally train and publicly release large neural language models on programs, including PolyCoder. Here, I describe

Vincent Hellendoorn 947 Dec 28, 2022
Code repository of the paper Neural circuit policies enabling auditable autonomy published in Nature Machine Intelligence

Code repository of the paper Neural circuit policies enabling auditable autonomy published in Nature Machine Intelligence

9 Jan 08, 2023
This project is part of Eleuther AI's quest to create a massive repository of high quality text data for training language models.

This project is part of Eleuther AI's quest to create a massive repository of high quality text data for training language models.

EleutherAI 42 Dec 13, 2022
Malaya-Speech is a Speech-Toolkit library for bahasa Malaysia, powered by Deep Learning Tensorflow.

Malaya-Speech is a Speech-Toolkit library for bahasa Malaysia, powered by Deep Learning Tensorflow. Documentation Proper documentation is available at

HUSEIN ZOLKEPLI 151 Jan 05, 2023
Active learning for text classification in Python

Active Learning allows you to efficiently label training data in a small-data scenario.

Webis 375 Dec 28, 2022
Prompt tuning toolkit for GPT-2 and GPT-Neo

mkultra mkultra is a prompt tuning toolkit for GPT-2 and GPT-Neo. Prompt tuning injects a string of 20-100 special tokens into the context in order to

61 Jan 01, 2023
Idea is to build a model which will take keywords as inputs and generate sentences as outputs.

keytotext Idea is to build a model which will take keywords as inputs and generate sentences as outputs. Potential use case can include: Marketing Sea

Gagan Bhatia 364 Jan 03, 2023