You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2023/03/13 11:59:37 UTC

[incubator-nlpcraft] branch master updated: fix time model to include map data

This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/master by this push:
     new 29380ce3 fix time model to include map data
     new fac299ef Merge pull request #84 from paulk-asert/timeModelFix
29380ce3 is described below

commit 29380ce387731dbd8e92e5402cb9b4760fe0144a
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Mar 13 12:20:02 2023 +1000

    fix time model to include map data
---
 .../main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala b/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala
index 5826f090..e563d80a 100644
--- a/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala
+++ b/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala
@@ -19,6 +19,7 @@ package org.apache.nlpcraft.examples.time
 import com.fasterxml.jackson.core.JsonProcessingException
 import com.fasterxml.jackson.databind.ObjectMapper
 import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
+import com.fasterxml.jackson.module.scala.DefaultScalaModule
 import org.apache.nlpcraft.*
 import org.apache.nlpcraft.annotations.*
 import org.apache.nlpcraft.examples.time.utils.cities.*
@@ -77,8 +78,11 @@ class TimeModel extends NCModel(
                 "localTime" -> ZonedDateTime.now(ZoneId.of(tmz)).format(FMT)
             )
 
-        try
-            NCResult(new ObjectMapper(new YAMLFactory).writeValueAsString(m))
+        try {
+            val mapper = new ObjectMapper(new YAMLFactory)
+            mapper.registerModule(DefaultScalaModule)
+            NCResult(mapper.writeValueAsString(m))
+        }
         catch
             case e: JsonProcessingException => throw new RuntimeException("YAML conversion error.", e)