From 0b67d6df6eb08c9479567595e9a80019a020b32d Mon Sep 17 00:00:00 2001 From: zhangsonglei Date: Mon, 25 Sep 2023 10:38:17 +0800 Subject: [PATCH] =?UTF-8?q?FIX=E5=8F=96=E6=B6=88=E6=9C=89=E6=AD=A7?= =?UTF-8?q?=E4=B9=89=E7=9A=84=E5=86=9C=E5=8E=86=E8=A1=A8=E8=BE=BE=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=B0=8F=E6=95=B0=E8=B4=9F=E5=80=BC=E8=A1=A8?= =?UTF-8?q?=E8=BE=BEvalue=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../duckling/dimension/numeral/Rules.scala | 2 +- .../dimension/time/date/LunarDates.scala | 16 +--------------- .../duckling/dimension/numeral/Examples.scala | 3 ++- .../duckling/dimension/time/date/Examples.scala | 2 +- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/numeral/Rules.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/numeral/Rules.scala index b214bf4e..3ff13406 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/numeral/Rules.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/numeral/Rules.scala @@ -105,7 +105,7 @@ trait Rules extends DimRules { } fractionPart.map { p => - val v = intPart + p + val v = if (intPart >= 0) intPart + p else intPart - p token(NumeralData(v, composable = false, precision = precision)) } } diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/LunarDates.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/LunarDates.scala index d704260a..7949dcac 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/LunarDates.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/date/LunarDates.scala @@ -45,20 +45,6 @@ object LunarDates { } ) - val ruleLunarSymbolDate2 = Rule( - name = " ", - pattern = List( - // 避免农历八月初八按[农历]八月初八和[农历八月]初八结合两次 - and(isTimeDatePredicate, isNotHint(Hint.Intersect), isNotHint(Hint.YearMonth)).predicate, - "的?(农|阴)历".regex - ), - prod = tokens { - case Token(Date, td: TimeData) :: _ => - val t = lunar(td).copy(calendar = Lunar(false), hint = Hint.Lunar) - Token(Date, t) - } - ) - val ruleLunarMonth = Rule( name = " 正/腊/冬", pattern = List("闰?(正|腊|冬)月".regex), @@ -97,5 +83,5 @@ object LunarDates { } ) - val rules = List(ruleLunarSymbolDate1, ruleLunarSymbolDate2, ruleLunarMonth, ruleLunarDayOfMonth) + val rules = List(ruleLunarSymbolDate1, ruleLunarMonth, ruleLunarDayOfMonth) } diff --git a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/numeral/Examples.scala b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/numeral/Examples.scala index e501a2fc..07bac663 100644 --- a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/numeral/Examples.scala +++ b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/numeral/Examples.scala @@ -76,7 +76,8 @@ object Examples extends DimExamples { ((1.45, 2), List("1点45")), ((1.4, 1), List("一点四")), ((1987.43, 2), List("一千九百八十七点四三")), - ((123.123, 3), List("123.123")) + ((123.123, 3), List("123.123")), + ((-100.3, 1), List("负一百点三")) ) override def pairs: List[(ResolvedValue, List[String])] = { diff --git a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/date/Examples.scala b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/date/Examples.scala index d4a9a186..37e8899c 100644 --- a/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/date/Examples.scala +++ b/duckling-fork-chinese/learning/src/main/scala/com/xiaomi/duckling/dimension/time/date/Examples.scala @@ -54,7 +54,7 @@ object Examples extends DimExamples { (ym(2001, 5), List("零一年五月")), (ymd(2013, 2, 28), List("月底")), // 2013.2.12 农历是 2013年正月初三 => 2014年正月初二 - (ymd(2014, 1, 2, calendar = Lunar(false)), List("农历一月初二", "正月初二", "农历的一月初二", "阴历的正月初二", "一月初二农历", "一月初二的农历")), + (ymd(2014, 1, 2, calendar = Lunar(false)), List("农历一月初二", "正月初二", "农历的一月初二", "阴历的正月初二")), (ymd(2013, 1, 18, calendar = Lunar(false)), List("农历一月十八", "正月十八")), (ymd(2013, 11, 8, calendar = Lunar(false)), List("农历十一月初八", "冬月初八")), (ymd(2013, 11, 22, calendar = Lunar(false)), List("农历十一月二十二", "冬月二十二")),