From 788ae5b608a08a14614f8e4f71960161bf32d0ea Mon Sep 17 00:00:00 2001 From: Ninglin Du Date: Fri, 12 Jul 2024 13:30:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=AC=A1=E6=97=A5?= =?UTF-8?q?=EF=BC=8C=E7=AC=AC=E4=BA=8C=E5=A4=A9=20=3D=20=E6=98=8E=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xiaomi/duckling/dimension/time/Rules.scala | 10 ++++++++++ .../com/xiaomi/duckling/dimension/time/Examples.scala | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala index 92d3e25..bf81d42 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala @@ -575,6 +575,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)) + } + ) + def openInterval(td: TimeData, direction: IntervalDirection): Option[Token] = { val pred = SequencePredicate(List(td, TimeData(TimeOpenIntervalPredicate(direction), timeGrain = Grain.NoGrain))) tt(TimeData(pred, timeGrain = td.timeGrain, hint = Hint.Sequence)) @@ -582,6 +591,7 @@ trait Rules extends DimRules { val composite = List( ruleRecentTime, + tomorrow, ruleNthTimeOfTime, ruleNthTimeOfTime2, ruleIntersect, diff --git a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala index ff3c855..d145cef 100644 --- a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala +++ b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala @@ -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("去年的今天")), From 9d31df39b906f38d6a5612bb1fce87e13dfb7cb5 Mon Sep 17 00:00:00 2001 From: Ninglin Du Date: Fri, 12 Jul 2024 16:10:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=AC=A1=E6=97=A5=20?= =?UTF-8?q?=3D=20=E6=98=8E=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xiaomi/duckling/dimension/time/Rules.scala | 10 ---------- .../xiaomi/duckling/dimension/time/date/Rules.scala | 11 ++++++++++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala index bf81d42..92d3e25 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/Rules.scala @@ -575,15 +575,6 @@ trait Rules extends DimRules { } ) - val tomorrow = Rule( - name = "次日|第二天", - pattern = List("次日|第二天".regex), - prod = tokens { - case Token(RegexMatch, GroupMatch(s :: _)) :: _ => - tt(cycleNthThis(1, Day, Day, Year)) - } - ) - def openInterval(td: TimeData, direction: IntervalDirection): Option[Token] = { val pred = SequencePredicate(List(td, TimeData(TimeOpenIntervalPredicate(direction), timeGrain = Grain.NoGrain))) tt(TimeData(pred, timeGrain = td.timeGrain, hint = Hint.Sequence)) @@ -591,7 +582,6 @@ trait Rules extends DimRules { val composite = List( ruleRecentTime, - tomorrow, ruleNthTimeOfTime, ruleNthTimeOfTime2, ruleIntersect, diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/Rules.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/Rules.scala index dec0e0a..b29ed1e 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/Rules.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/Rules.scala @@ -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} @@ -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), From 99cf89b4214d3de632749225314294949d03f629 Mon Sep 17 00:00:00 2001 From: Ninglin Du Date: Fri, 12 Jul 2024 16:11:46 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=AC=A1=E6=97=A5=20?= =?UTF-8?q?=3D=20=E6=98=8E=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/com/xiaomi/duckling/dimension/time/Examples.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala index d145cef..7b4b854 100644 --- a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala +++ b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/Examples.scala @@ -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("去年的今天")),