From d922404d035331eb615232a225c3f52916cbfb34 Mon Sep 17 00:00:00 2001 From: Waqas Shabir Date: Mon, 1 Feb 2016 23:29:36 +0500 Subject: [PATCH 1/5] Fixed issue with chinese dates with component numbers --- data/languages.yaml | 3 +++ tests/test_date_parser.py | 3 +++ tests/test_languages.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/data/languages.yaml b/data/languages.yaml index 66af6863a..764c47aec 100644 --- a/data/languages.yaml +++ b/data/languages.yaml @@ -1124,6 +1124,7 @@ cn: - 星期 day: - 天 + - 日 hour: - 小时 minute: @@ -1138,6 +1139,8 @@ cn: simplifications: - 昨天: 1天 - 前天: 2天 + - (\d+)年(\d+)月(\d+)日(\d+):(\d+): \1-\2-\3 \4:\5 + - (\d+)年(\d+)月(\d+)日: \1-\2-\3 nl: diff --git a/tests/test_date_parser.py b/tests/test_date_parser.py index b831da8a5..db2dd35b5 100644 --- a/tests/test_date_parser.py +++ b/tests/test_date_parser.py @@ -306,6 +306,9 @@ def setUp(self): param('06-17-2014', datetime(2014, 6, 17)), param('13/03/2014', datetime(2014, 3, 13)), param('11. 12. 2014, 08:45:39', datetime(2014, 11, 12, 8, 45, 39)), + # Chinese dates + param('2015年04月08日10:05', datetime(2015, 4, 8, 10, 05)), + param('2012年12月20日10:35', datetime(2012, 12, 20, 10, 35)), ]) def test_dates_parsing(self, date_string, expected): self.given_utcnow(datetime(2012, 11, 13)) # Tuesday diff --git a/tests/test_languages.py b/tests/test_languages.py index 8d229f4be..edad1b49e 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -24,6 +24,8 @@ def setUp(self): param('en', "friday, 03 september 2014", "friday 03 september 2014"), # Chinese param('cn', "1年11个月", "1 year 11 month"), + param('cn', "2015年04月08日10:05", "2015-04-08 10:05"), + param('cn', "2013年04月08日", "2013-04-08"), # French param('fr', "20 Février 2012", "20 february 2012"), param('fr', "Mercredi 19 Novembre 2013", "wednesday 19 november 2013"), From d2ed1346bbf9a7aab005cdb283a6e233a22032cc Mon Sep 17 00:00:00 2001 From: Waqas Shabir Date: Mon, 8 Feb 2016 18:41:12 +0500 Subject: [PATCH 2/5] Added spaces to the simplification for chinese date with numbered components --- data/languages.yaml | 4 ++-- tests/test_date_parser.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/languages.yaml b/data/languages.yaml index 764c47aec..ae037ecad 100644 --- a/data/languages.yaml +++ b/data/languages.yaml @@ -1139,8 +1139,8 @@ cn: simplifications: - 昨天: 1天 - 前天: 2天 - - (\d+)年(\d+)月(\d+)日(\d+):(\d+): \1-\2-\3 \4:\5 - - (\d+)年(\d+)月(\d+)日: \1-\2-\3 + - (\d+)年(?:\s+)?(\d+)月(?:\s+)?(\d+)日(?:\s+)?(\d+):(\d+): \1-\2-\3 \4:\5 + - (\d+)年(?:\s+)?(\d+)月(?:\s+)?(\d+)日: \1-\2-\3 nl: diff --git a/tests/test_date_parser.py b/tests/test_date_parser.py index db2dd35b5..28616b2cf 100644 --- a/tests/test_date_parser.py +++ b/tests/test_date_parser.py @@ -307,8 +307,9 @@ def setUp(self): param('13/03/2014', datetime(2014, 3, 13)), param('11. 12. 2014, 08:45:39', datetime(2014, 11, 12, 8, 45, 39)), # Chinese dates - param('2015年04月08日10:05', datetime(2015, 4, 8, 10, 05)), + param('2015年04月08日10:05', datetime(2015, 4, 8, 10, 5)), param('2012年12月20日10:35', datetime(2012, 12, 20, 10, 35)), + param('2016年 2月 5日', datetime(2016, 2, 5, 0, 0)), ]) def test_dates_parsing(self, date_string, expected): self.given_utcnow(datetime(2012, 11, 13)) # Tuesday From 76117c6ea6e8c0c3c33e68bd1645d5fde8fc4b0b Mon Sep 17 00:00:00 2001 From: Waqas Shabir Date: Wed, 27 Apr 2016 23:33:43 +0500 Subject: [PATCH 3/5] Revert "Added spaces to the simplification for chinese date with numbered components" This reverts commit d2ed1346bbf9a7aab005cdb283a6e233a22032cc. --- data/languages.yaml | 4 ++-- tests/test_date_parser.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/data/languages.yaml b/data/languages.yaml index ae037ecad..764c47aec 100644 --- a/data/languages.yaml +++ b/data/languages.yaml @@ -1139,8 +1139,8 @@ cn: simplifications: - 昨天: 1天 - 前天: 2天 - - (\d+)年(?:\s+)?(\d+)月(?:\s+)?(\d+)日(?:\s+)?(\d+):(\d+): \1-\2-\3 \4:\5 - - (\d+)年(?:\s+)?(\d+)月(?:\s+)?(\d+)日: \1-\2-\3 + - (\d+)年(\d+)月(\d+)日(\d+):(\d+): \1-\2-\3 \4:\5 + - (\d+)年(\d+)月(\d+)日: \1-\2-\3 nl: diff --git a/tests/test_date_parser.py b/tests/test_date_parser.py index 28616b2cf..db2dd35b5 100644 --- a/tests/test_date_parser.py +++ b/tests/test_date_parser.py @@ -307,9 +307,8 @@ def setUp(self): param('13/03/2014', datetime(2014, 3, 13)), param('11. 12. 2014, 08:45:39', datetime(2014, 11, 12, 8, 45, 39)), # Chinese dates - param('2015年04月08日10:05', datetime(2015, 4, 8, 10, 5)), + param('2015年04月08日10:05', datetime(2015, 4, 8, 10, 05)), param('2012年12月20日10:35', datetime(2012, 12, 20, 10, 35)), - param('2016年 2月 5日', datetime(2016, 2, 5, 0, 0)), ]) def test_dates_parsing(self, date_string, expected): self.given_utcnow(datetime(2012, 11, 13)) # Tuesday From 91f75b9dde520e0bf2abef4a4a025fd73c5bb833 Mon Sep 17 00:00:00 2001 From: Waqas Shabir Date: Wed, 27 Apr 2016 23:34:14 +0500 Subject: [PATCH 4/5] Revert "Fixed issue with chinese dates with component numbers" This reverts commit d922404d035331eb615232a225c3f52916cbfb34. --- data/languages.yaml | 3 --- tests/test_date_parser.py | 3 --- tests/test_languages.py | 2 -- 3 files changed, 8 deletions(-) diff --git a/data/languages.yaml b/data/languages.yaml index 764c47aec..66af6863a 100644 --- a/data/languages.yaml +++ b/data/languages.yaml @@ -1124,7 +1124,6 @@ cn: - 星期 day: - 天 - - 日 hour: - 小时 minute: @@ -1139,8 +1138,6 @@ cn: simplifications: - 昨天: 1天 - 前天: 2天 - - (\d+)年(\d+)月(\d+)日(\d+):(\d+): \1-\2-\3 \4:\5 - - (\d+)年(\d+)月(\d+)日: \1-\2-\3 nl: diff --git a/tests/test_date_parser.py b/tests/test_date_parser.py index db2dd35b5..b831da8a5 100644 --- a/tests/test_date_parser.py +++ b/tests/test_date_parser.py @@ -306,9 +306,6 @@ def setUp(self): param('06-17-2014', datetime(2014, 6, 17)), param('13/03/2014', datetime(2014, 3, 13)), param('11. 12. 2014, 08:45:39', datetime(2014, 11, 12, 8, 45, 39)), - # Chinese dates - param('2015年04月08日10:05', datetime(2015, 4, 8, 10, 05)), - param('2012年12月20日10:35', datetime(2012, 12, 20, 10, 35)), ]) def test_dates_parsing(self, date_string, expected): self.given_utcnow(datetime(2012, 11, 13)) # Tuesday diff --git a/tests/test_languages.py b/tests/test_languages.py index edad1b49e..8d229f4be 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -24,8 +24,6 @@ def setUp(self): param('en', "friday, 03 september 2014", "friday 03 september 2014"), # Chinese param('cn', "1年11个月", "1 year 11 month"), - param('cn', "2015年04月08日10:05", "2015-04-08 10:05"), - param('cn', "2013年04月08日", "2013-04-08"), # French param('fr', "20 Février 2012", "20 february 2012"), param('fr', "Mercredi 19 Novembre 2013", "wednesday 19 november 2013"), From 65e3d72129820e5efa3be5195d2b466fea927c82 Mon Sep 17 00:00:00 2001 From: Waqas Shabir Date: Wed, 27 Apr 2016 23:42:13 +0500 Subject: [PATCH 5/5] Resynced changes with master --- data/languagefiles/zh.yaml | 3 +++ tests/test_date_parser.py | 4 ++++ tests/test_languages.py | 2 ++ 3 files changed, 9 insertions(+) diff --git a/data/languagefiles/zh.yaml b/data/languagefiles/zh.yaml index 7cd14c0d6..81ae8d799 100644 --- a/data/languagefiles/zh.yaml +++ b/data/languagefiles/zh.yaml @@ -53,6 +53,7 @@ week: - 星期 day: - 天 + - 日 hour: - 小时 minute: @@ -67,4 +68,6 @@ ago: simplifications: - 昨天: 1天 - 前天: 2天 + - (\d+)年(?:\s+)?(\d+)月(?:\s+)?(\d+)日(?:\s+)?(\d+):(\d+): \1-\2-\3 \4:\5 + - (\d+)年(?:\s+)?(\d+)月(?:\s+)?(\d+)日: \1-\2-\3 diff --git a/tests/test_date_parser.py b/tests/test_date_parser.py index 5a50bd011..257c2797f 100644 --- a/tests/test_date_parser.py +++ b/tests/test_date_parser.py @@ -328,6 +328,10 @@ def setUp(self): param('1 Mar 2015', datetime(2015, 3, 1, 0, 0)), param('1 Paz 2015', datetime(2015, 10, 1, 0, 0)), param('1 сер 2015', datetime(2015, 8, 1, 0, 0)), + # Chinese dates + param('2015年04月08日10:05', datetime(2015, 4, 8, 10, 5)), + param('2012年12月20日10:35', datetime(2012, 12, 20, 10, 35)), + param('2016年 2月 5日', datetime(2016, 2, 5, 0, 0)), ]) def test_dates_parsing(self, date_string, expected): self.given_utcnow(datetime(2012, 11, 13)) # Tuesday diff --git a/tests/test_languages.py b/tests/test_languages.py index 14ecc4564..5ac8a1173 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -24,6 +24,8 @@ def setUp(self): param('en', "friday, 03 september 2014", "friday 03 september 2014"), # Chinese param('zh', "1年11个月", "1 year 11 month"), + param('zh', "2015年04月08日10:05", "2015-04-08 10:05"), + param('zh', "2013年04月08日", "2013-04-08"), # French param('fr', "20 Février 2012", "20 february 2012"), param('fr', "Mercredi 19 Novembre 2013", "wednesday 19 november 2013"),