From 859e2fa5f1b17c7a83766c5ddde6feaed760d115 Mon Sep 17 00:00:00 2001 From: Ninglin Du Date: Fri, 26 Jul 2024 11:49:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=89=8D=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=AE=B5=E4=B8=8D=E5=9C=A8=E8=BF=87=E5=8E=BB=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/com/xiaomi/duckling/dimension/time/package.scala | 2 +- .../com/xiaomi/duckling/dimension/time/TimeDataTest.scala | 5 +++-- .../scala/com/xiaomi/duckling/task/NaiveBayesConsole.scala | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/package.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/package.scala index b0aaf5ba..af1c19bf 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/package.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/package.scala @@ -93,7 +93,7 @@ package object time { case ahead #:: _ => val happened = td.timePred match { - case _: TimeDatePredicate => timeBefore(ahead, refTime, td.timeGrain) + case _: TimeDatePredicate | _: TimeIntervalsPredicate => timeStartsBeforeTheEndOf(ahead)(refTime) case _ => false } if (happened) Some(ahead) diff --git a/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/dimension/time/TimeDataTest.scala b/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/dimension/time/TimeDataTest.scala index ada9dc6e..20a6b0eb 100644 --- a/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/dimension/time/TimeDataTest.scala +++ b/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/dimension/time/TimeDataTest.scala @@ -44,8 +44,9 @@ class TimeDataTest extends UnitSpec with LazyLogging { } } - val testCases = Table( ("query", "year", "month", "day"), - ("最近三天", 2013, 2, 9) + val testCases = Table( ("query", "year", "month", "day") + , ("凌晨", 2013, 2, 12) + , ("最近三天", 2013, 2, 9) , ("过去三天", 2013, 2, 9) , ("昨天", 2013, 2, 11) , ("今天", 2013, 2, 12) diff --git a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/task/NaiveBayesConsole.scala b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/task/NaiveBayesConsole.scala index 5b35c38d..24c611a0 100644 --- a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/task/NaiveBayesConsole.scala +++ b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/task/NaiveBayesConsole.scala @@ -77,7 +77,9 @@ object NaiveBayesConsole extends LazyLogging { "seasons", "sequence", "fuzzy-on", - "before-end-of-interval" + "before-end-of-interval", + "recent-in-future", + "always-in-future" ), NullCompleter.INSTANCE ) @@ -127,6 +129,8 @@ object NaiveBayesConsole extends LazyLogging { case "sequence" => options.timeOptions.setSequence(value); options case "fuzzy-on" => options.timeOptions.setDurationFuzzyOn(value); options case "before-end-of-interval" => options.timeOptions.setBeforeEndOfInterval(value); options + case "recent-in-future" => options.timeOptions.setRecentInFuture(value); options + case "always-in-future" => options.timeOptions.setAlwaysInFuture(value); options case _ => options } opt