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