Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Japanese support #1068

Merged
merged 2 commits into from Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions dateparser/data/date_translation_data/ja.py
Expand Up @@ -172,6 +172,9 @@
],
"2 week ago": [
"先々週"
],
"in 2 day": [
"明後日"
]
},
"relative-type-regex": {
Expand Down Expand Up @@ -250,6 +253,9 @@
"|",
","
],
"pertain": [
"の"
],
"ago": [
"前"
],
Expand All @@ -272,6 +278,9 @@
},
{
"(\\d+[.,]?\\d*)時$": "\\1:00"
},
{
"正午": "12:00"
}
]
}
Expand Up @@ -4,6 +4,8 @@ sentence_splitter_group : 4

skip: ["約"]

pertain: ["の"]

monday:
- (月)
tuesday:
Expand Down Expand Up @@ -73,10 +75,13 @@ relative-type:
- 先々週
1 year ago:
- 去年
in 2 day:
- 明後日

simplifications:
- (\d+[.,]?\d*)年(?:\s+)?(\d+[.,]?\d*)月(?:\s+)?(\d+[.,]?\d*)日: \1-\2-\3
- (\d+[.,]?\d*)月(?:\s+)?(\d+[.,]?\d*)日: \1-\2
- (\d+[.,]?\d*)時(?:\s+)?(\d+[.,]?\d*)分(?:\s+)?(\d+[.,]?\d*)秒: \1:\2:\3
- (\d+[.,]?\d*)時(?:\s+)?(\d+[.,]?\d*)分: \1:\2
- (\d+[.,]?\d*)時$: \1:00
- 正午: '12:00'
3 changes: 3 additions & 0 deletions tests/test_languages.py
Expand Up @@ -191,6 +191,8 @@ def setUp(self):
param('ja', "2016年3月21日(月) 14時48分", "2016-3-21 monday 14:48"),
param('ja', "2016年3月20日(日) 21時40分", "2016-3-20 sunday 21:40"),
param('ja', "2016年3月20日 (日) 21時40分", "2016-3-20 sunday 21:40"),
param('ja', "正午", "12:00"),
param('ja', "明日の13時20分", "in 1 day 13:20"),

# Hebrew
param('he', "20 לאפריל 2012", "20 april 2012"),
Expand Down Expand Up @@ -1070,6 +1072,7 @@ def test_translation(self, shortname, datetime_string, expected_translation):
param('ja', "60秒", "60 second"),
param('ja', "3秒前", "3 second ago"),
param('ja', "現在", "0 second ago"),
param('ja', "明後日", "in 2 day"),
# Hebrew
param('he', "אתמול", "1 day ago"),
param('he', "אתמול בשעה 3", "1 day ago 3"),
Expand Down
3 changes: 3 additions & 0 deletions tests/test_search.py
Expand Up @@ -189,6 +189,9 @@ def check_error_message(self, message):
param('ja', "2016年3月21日(月) 14時48分"),
param('ja', "2016年3月20日(日) 21時40分"),
param('ja', "2016年3月20日 (日) 21時40分"),
param('ja', "正午"),
param('ja', "明後日"),
param('ja', "明後日の正午"),

# Hebrew
param('he', "20 לאפריל 2012"),
Expand Down