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

Added words in Chinese related to relative time #811

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 62 additions & 26 deletions dateparser/data/date_translation_data/zh-Hans.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
info = {
"name": "zh-Hans",
"name": "zh",
"date_order": "YMD",
"january": [
"一月",
Expand Down Expand Up @@ -51,31 +51,40 @@
],
"monday": [
"星期一",
"周一"
"周一",
"礼拜一"
],
"tuesday": [
"星期二",
"周二"
"周二",
"礼拜二"
],
"wednesday": [
"星期三",
"周三"
"周三",
"礼拜三"
],
"thursday": [
"星期四",
"周四"
"周四",
"礼拜四"
],
"friday": [
"星期五",
"周五"
"周五",
"礼拜五"
],
"saturday": [
"星期六",
"周六"
"周六",
"礼拜六"
],
"sunday": [
"星期日",
"周日"
"周日",
"星期天",
"礼拜日",
"礼拜天"
],
"am": [
"上午"
Expand All @@ -87,13 +96,17 @@
"年"
],
"month": [
"月"
"月",
"个月",
"個月"
],
"week": [
"周"
"周",
"星期"
],
"day": [
"日"
"日",
"天"
],
"hour": [
"小时"
Expand Down Expand Up @@ -150,6 +163,9 @@
],
"0 second ago": [
"现在"
],
"2 day ago": [
"前天"
]
},
"relative-type-regex": {
Expand Down Expand Up @@ -198,23 +214,11 @@
"(\\d+)秒前"
]
},
"locale_specific": {
"zh-Hans-SG": {
"name": "zh-Hans-SG",
"date_order": "DMY"
},
"zh-Hans-HK": {
"name": "zh-Hans-HK",
"date_order": "DMY"
},
"zh-Hans-MO": {
"name": "zh-Hans-MO",
"date_order": "DMY"
}
},
"locale_specific": {},
"no_word_spacing": "True",
"sentence_splitter_group": 4,
"skip": [
"约",
" ",
".",
",",
Expand All @@ -227,5 +231,37 @@
"[",
"]",
","
],
"ago": [
"前"
],
"in": [
"在"
],
"simplifications": [
{
"半小时前": "30分前"
},
{
"(?:中午|下午|(?:晚上?))(?:\\s*)(\\d+)(?:\\s*):(?:\\s+|:)?(\\d+)": "\\1:\\2 pm"
},
{
"(?:上午|早上|凌晨)(?:\\s*)(\\d+)(?:\\s*):(?:\\s+|:)?(\\d+)": "\\1:\\2 am"
},
{
"中午": "12:00"
},
{
"(\\d+)年(?:\\s+)?(\\d+)月(?:\\s+)?(\\d+)日(?:\\s+)?(\\d+)时(?:\\s+)?(\\d+)分": "\\1-\\2-\\3 \\4:\\5"
},
{
"(\\d+)年(?:\\s+)?(\\d+)月(?:\\s+)?(\\d{1,2})(?:日)?(?:\\s+)?(\\d{1,2})(?:点|:)(\\d{1,2})": "\\1-\\2-\\3 \\4:\\5"
},
{
"(\\d+)年(?:\\s+)?(\\d+)月(?:\\s+)?(\\d{1,2})(?:日)?": "\\1-\\2-\\3"
},
{
"(\\d+)月(?=.*[前后])": "\\1 月"
}
]
}
}
45 changes: 38 additions & 7 deletions dateparser/data/date_translation_data/zh.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"下午"
],
"year": [
"年"
"年",
"年度"
],
"month": [
"月",
Expand All @@ -102,7 +103,8 @@
],
"week": [
"周",
"星期"
"星期",
"礼拜"
],
"day": [
"日",
Expand Down Expand Up @@ -173,31 +175,60 @@
"(\\d+)年后"
],
"\\1 year ago": [
"(\\d+)年前"
"(\\d+)年前",
"(\\d+)载前",
"前一(\\d+)年",
"前一(\\d+)载",
],
"in \\1 month": [
"(\\d+)个月后"
],
"\\1 month ago": [
"(\\d+)个月前",
"(\\d+)月前",
"(\\d+)月前"
"(\\d+)个月前"
"前一(\\d+)月"
"前一(\\d+)个月"
],
"in \\1 week": [
"(\\d+)周后"
"(\\d+)周后",
],
"\\1 week ago": [
"(\\d+)周前"
"(\\d+)周前",
"(\\d+)个周前",
"(\\d+)星期前",
"(\\d+)个星期前",
"(\\d+)礼拜前",
"(\\d+)个礼拜前",
"前一(\\d+)周",
"前一(\\d+)星期",
"前一(\\d+)个星期",
"前一(\\d+)礼拜",
"前一(\\d+)个礼拜"
],
"in \\1 day": [
"(\\d+)天后"
],
"\\1 day ago": [
"(\\d+)天前"
"(\\d+)天前",
"(\\d+)日前",
"前一(\\d+)天",
"前一(\\d+)日",

],
"in \\1 hour": [
"(\\d+)小时后"
],
"\\1 hour ago": [
"(\\d+)小时前"
"(\\d+)小时前",
"(\\d+)钟头前",
"(\\d+)个小时前",
"(\\d+)个钟头前",
"前一(\\d+)小时",
"前一(\\d+)个小时",
"前一(\\d+)钟头",
"前一(\\d+)个钟头"
],
"in \\1 minute": [
"(\\d+)分钟后"
Expand Down