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 3b6c6f3..8cdda10 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 @@ -255,6 +255,8 @@ trait Rules extends DimRules { case Week => (reset(Week) _ >>> tt)(td) case _ => tt(td) } + } else if (s != "这" && g == Week) { // 最?近一周,改为最近7天。 + cycleN(notImmediate = false, Day, 7 * v).map(t => tt(t.at(Hint.Recent))) } else tt(cycleNth(g, 0)) case "上" | "前" | "之前" | "往前" | "向前" | "过去" | "过去" => if (s == "上" && (g == Day || g == Year)) None diff --git a/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/ApiTest.scala b/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/ApiTest.scala index a60a664..1764bc6 100644 --- a/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/ApiTest.scala +++ b/duckling-fork-chinese/core/src/test/scala/com/xiaomi/duckling/ApiTest.scala @@ -47,7 +47,7 @@ class ApiTest extends UnitSpec { it("should date") { val options = testOptions.copy(targets = Set(Numeral, Time, Duration, Date), full = false) - println(Api.analyze("一年前的今天", testContext, options)) + println(Api.analyze("最近一周", testContext, options)) } it("should age") { 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 0a5b284..cb298d8 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 @@ -218,7 +218,15 @@ object Examples extends DimExamples { Minute ), List("未来一刻钟", "之后一刻钟", "向后一刻钟", "往后一刻钟", "一刻钟以内") - ) + ), + ( + localDateTimeInterval( + LocalDateTime.of(2013, 2, 12, 0, 0, 0), + LocalDateTime.of(2013, 2, 19, 0, 0, 0), + Day + ), + List("最近一周", "最近一星期", "近七天") + ) ) val weeks = List(