From 88b733cbfe27206641296c1846f9dcb77cca48b0 Mon Sep 17 00:00:00 2001 From: Ninglin Du Date: Tue, 27 Feb 2024 19:17:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=8A=82=E6=97=A5=E5=90=8C=E5=90=8D?= =?UTF-8?q?=E4=BC=98=E5=85=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../duckling/dimension/time/helper/HolidayProvider.scala | 8 ++++++-- .../com/xiaomi/duckling/dimension/time/Examples.scala | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala index f6e4c118..7c44030c 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala @@ -184,7 +184,6 @@ class LocalHolidayProvider extends HolidayProvider { (monthDay(4, 23), "世界读书日", "世界读书日|读书日"), (monthDay(4, 26), "国际知识产权日", "国际知识产权日|知识产权日"), (monthDay(4, 30), "国际爵士日", "国际爵士日|爵士日"), - (monthDay(4, 4), "台湾儿童节", "台湾儿童节|儿童节"), (monthDay(4, 6), "米粉节", "米粉节"), (monthDay(5, 1), "劳动节", "五一国际劳动节|51国际劳动节|国际劳动节|五一劳动节|劳动节|五一"), (monthDay(5, 12), "护士节", "护士节"), @@ -197,6 +196,7 @@ class LocalHolidayProvider extends HolidayProvider { (monthDay(5, 4), "五四青年节", "中国五四青年节|五四青年节|中国54青年节|54青年节|中国青年节|青年节"), (monthDay(5, 8), "世界红十字日", "世界红十字日"), (monthDay(6, 1), "儿童节", "国际六一儿童节|六一儿童节|国际61儿童节|61儿童节|儿童节|六一"), + (monthDay(4, 4), "台湾儿童节", "台湾儿童节|儿童节"), (monthDay(6, 11), "中国人口日", "中国人口日"), (monthDay(6, 14), "世界献血日", "世界献血日"), (monthDay(6, 15), "健康素食日", "健康素食日"), @@ -279,7 +279,11 @@ class LocalHolidayProvider extends HolidayProvider { val builder = Maps.newTreeMap[String, String]() normalMap.foreach{ - case (pt, normalSet) => normalSet.foreach(normal => builder.put(pt, normal)) + case (pt, normalSet) => normalSet.foreach(normal => + if (pt == normal && normal.contains(pt) || !normal.contains(pt)) { + builder.put(pt, normal) + } + ) } val tokenMapBuilder = ImmutableMap.builder[String, Token]() tokenMap.toMap.foreach{case (k, v) => tokenMapBuilder.put(k, v)} 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 091e04b5..1d3a050e 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 @@ -301,7 +301,7 @@ object Examples extends DimExamples { (ymd(2014, 1, 1, holiday = "元旦节"), List("元旦", "元旦节", "阳历新年")), (ymd(2013, 3, 8, holiday = "妇女节"), List("妇女节")), (ymd(2013, 5, 1, holiday = "劳动节"), List("劳动节", "五一国际劳动节")), - (ymd(2013, 6, 1, holiday = "儿童节"), List("61儿童节")), + (ymd(2013, 6, 1, holiday = "儿童节"), List("儿童节")), (ymd(2013, 8, 1, holiday = "建军节"), List("建军节", "八一建军节")), (ymd(2013, 12, 25, holiday = "圣诞节"), List("圣诞", "圣诞节")), (ymd(2013, 4, 1, holiday = "愚人节"), List("愚人节")), @@ -309,6 +309,8 @@ object Examples extends DimExamples { (ymd(2013, 12, 20, holiday = "澳门回归纪念日"), List("澳门回归纪念日")), (ymd(2013, 2, 14, holiday = "情人节"), List("情人节", "圣瓦伦丁节")), (ymd(2013, 3, 15, holiday = "国际消费者权益日"), List("国际消费者权益日", "三一五")), + (ymd(2013, 6, 16, holiday = "父亲节"), List("父亲节")), + (ymd(2013, 11, 28, holiday = "感恩节"), List("感恩节")), (ymd(2013, 5, 12, holiday = "母亲节"), List("母亲节")), (ymd(2013, 8, 8, holiday = "台湾父亲节"), List("台湾父亲节")), (ymd(2013, 10, 1, holiday = "国庆节"), List("国庆节", "十一", "国庆")), From fee08b20dbdb512f7ca4a0184e50a22d93f72934 Mon Sep 17 00:00:00 2001 From: Ninglin Du Date: Tue, 27 Feb 2024 19:51:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xiaomi/duckling/dimension/time/helper/HolidayProvider.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala index 7c44030c..1ca869b9 100644 --- a/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala +++ b/duckling-fork-chinese/core/src/main/scala/com/xiaomi/duckling/dimension/time/helper/HolidayProvider.scala @@ -280,7 +280,7 @@ class LocalHolidayProvider extends HolidayProvider { val builder = Maps.newTreeMap[String, String]() normalMap.foreach{ case (pt, normalSet) => normalSet.foreach(normal => - if (pt == normal && normal.contains(pt) || !normal.contains(pt)) { + if (!builder.containsKey(pt) || builder.containsKey(pt) && pt == normal) { builder.put(pt, normal) } )