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

[DUCK] 增加 次日/第二天 = 明天 #225

Merged
merged 3 commits into from
Jul 12, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.xiaomi.duckling.dimension.matcher.{GroupMatch, RegexMatch}
import com.xiaomi.duckling.dimension.matcher.Prods.{regexMatch, singleRegexMatch}
import com.xiaomi.duckling.dimension.numeral.Predicates.{getIntValue, isIntegerBetween}
import com.xiaomi.duckling.dimension.numeral.seq.{DigitSequence, DigitSequenceData}
import com.xiaomi.duckling.dimension.time.Prods.intersectDOM
import com.xiaomi.duckling.dimension.time.Prods.{intersectDOM, tt}
import com.xiaomi.duckling.dimension.time.duration.{isADecade, Duration, DurationData}
import com.xiaomi.duckling.dimension.time.enums.Grain._
import com.xiaomi.duckling.dimension.time.enums.Hint.{NoHint, RecentNominal, YearMonth}
Expand Down Expand Up @@ -229,6 +229,15 @@ trait Rules extends DimRules {
}
)

val tomorrow = Rule(
name = "次日",
pattern = List("次日".regex),
prod = tokens {
case Token(RegexMatch, GroupMatch(s :: _)) :: _ =>
tt(cycleNthThis(1, Day, Day, Year))
}
)

val ruleDecade = Rule(
name = "date: tens of decade",
pattern = List(isADecade.predicate, "年代".regex),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object Examples extends DimExamples {
// 有一部分在Date中已经定义了
(ymd(2013, 2, 12), List("今天", "今日", "2.12", "02.12")),
(ymd(2013, 2, 11), List("昨天", "昨日")),
(ymd(2013, 2, 13), List("明天", "明日")),
(ymd(2013, 2, 13), List("明天", "明日", "次日")),
(ymd(2013, 2, 14), List("后天", "后日")),
(ymd(2013, 2, 10), List("前天", "前日")),
(ymd(2012, 2, 12), List("去年的今天")),
Expand Down
Loading