Skip to content

Commit

Permalink
Value before month in zh can be an integers or a chinese char (facebo…
Browse files Browse the repository at this point in the history
…ok#301)

Summary:
May 2019 is more often written like' 2019年5月' than ' 2019年五月' so the corresponding integer are added in the regex's rule ruleMonths.
Pull Request resolved: facebook#301

Reviewed By: haoxuany

Differential Revision: D13606127

Pulled By: patapizza

fbshipit-source-id: 7dd2536e36711b4be42a93419b08dbd66cf31523
  • Loading branch information
EnzoTheBrown authored and facebook-github-bot committed Jan 14, 2019
1 parent 7d6af43 commit a707be9
Show file tree
Hide file tree
Showing 7 changed files with 514 additions and 648 deletions.
226 changes: 101 additions & 125 deletions Duckling/Ranking/Classifiers/ZH_CN.hs

Large diffs are not rendered by default.

226 changes: 101 additions & 125 deletions Duckling/Ranking/Classifiers/ZH_HK.hs

Large diffs are not rendered by default.

226 changes: 101 additions & 125 deletions Duckling/Ranking/Classifiers/ZH_MO.hs

Large diffs are not rendered by default.

226 changes: 101 additions & 125 deletions Duckling/Ranking/Classifiers/ZH_TW.hs

Large diffs are not rendered by default.

224 changes: 100 additions & 124 deletions Duckling/Ranking/Classifiers/ZH_XX.hs

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions Duckling/Time/ZH/Corpus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -275,26 +275,29 @@ allExamples = concat
, "下礼拜"
, "下禮拜"
]
, examples (datetime (2013, 1, 0, 0, 0, 0) Month)
, examples (datetime (2013, 1, 1, 0, 0, 0) Month)
[ "上月"
, "上个月"
, "上個月"
]
, examples (datetime (2013, 3, 0, 0, 0, 0) Month)
, examples (datetime (2013, 3, 1, 0, 0, 0) Month)
[ "下月"
, "下个月"
, "下個月"
, "3月"
, "3月份"
, "三月"
]
, examples (datetime (2012, 0, 0, 0, 0, 0) Year)
, examples (datetime (2012, 1, 1, 0, 0, 0) Year)
[ "去年"
, "上年"
]
, examples (datetime (2013, 0, 0, 0, 0, 0) Year)
, examples (datetime (2013, 1, 1, 0, 0, 0) Year)
[ "今年"
, "这一年"
, "這一年"
]
, examples (datetime (2014, 0, 0, 0, 0, 0) Year)
, examples (datetime (2014, 1, 1, 0, 0, 0) Year)
[ "明年"
, "下年"
]
Expand Down
21 changes: 2 additions & 19 deletions Duckling/Time/ZH/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,12 @@ ruleMonthNumericWithMonthSymbol = Rule
{ name = "month (numeric with month symbol)"
, pattern =
[ Predicate $ isIntegerBetween 1 12
, regex ""
, regex "(份)?"
]
, prod = \tokens -> case tokens of
(token:_) -> do
v <- getIntValue token
tt . mkLatent $ month v
tt . mkOkForThisNext $ month v
_ -> Nothing
}

Expand Down Expand Up @@ -892,22 +892,6 @@ ruleDaysOfWeek = mkRuleDaysOfWeek
, ( "Sunday", "星期日|星期天|礼拜天|周日|禮拜天|週日|禮拜日" )
]

ruleMonths :: [Rule]
ruleMonths = mkRuleMonths
[ ( "January", "一月(份)?" )
, ( "February", "二月(份)?" )
, ( "March", "三月(份)?" )
, ( "April", "四月(份)?" )
, ( "May", "五月(份)?" )
, ( "June", "六月(份)?" )
, ( "July", "七月(份)?" )
, ( "August", "八月(份)?" )
, ( "September", "九月(份)?" )
, ( "October", "十月(份)?" )
, ( "November", "十一月(份)?" )
, ( "December", "十二月(份)?" )
]

rulePeriodicHolidays :: [Rule]
rulePeriodicHolidays = mkRuleHolidays
-- Fixed dates, year over year
Expand Down Expand Up @@ -1039,5 +1023,4 @@ rules =
, ruleTimezone
]
++ ruleDaysOfWeek
++ ruleMonths
++ rulePeriodicHolidays

0 comments on commit a707be9

Please sign in to comment.