From d413f7074048e9b9ddbeacb04fcf78bb055ea1c2 Mon Sep 17 00:00:00 2001 From: zhangsonglei Date: Thu, 1 Feb 2024 17:56:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=80=E8=BF=91=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AEtimeoption=E8=87=AA=E5=AE=9A=E4=B9=89=E6=98=AF?= =?UTF-8?q?=E6=9C=AA=E6=9D=A5=E6=97=B6=E9=97=B4=E8=BF=98=E6=98=AF=E8=BF=87?= =?UTF-8?q?=E5=8E=BB=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xiaomi/duckling/dimension/time/date/Rules.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 c3cd130..89bf0e2 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 @@ -270,8 +270,13 @@ trait Rules extends DimRules { pattern = List("(最近|近期|这段时间)".regex), prod = { case (options, _) => - val from = cycleNth(Day, 0, Day) - val to = cycleNth(Day, 2, Day) + val fuzzyValue = options.timeOptions.durationFuzzyValue - 1 + val (from, to) = if (options.timeOptions.recentInFuture && options.timeOptions.alwaysInFuture) { + (cycleNth(Day, 0, Day), cycleNth(Day, fuzzyValue, Day)) + } else { + (cycleNth(Day, -fuzzyValue, Day), cycleNth(Day, 0, Day)) + } + for (td <- interval(Open, from, to, options.timeOptions.beforeEndOfInterval)) yield { Token(Date, td.copy(hint = Hint.UncertainRecent)) }