From 9a29c1d4f33dfb7d9b1f91ab629a701bab5b8016 Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Mon, 28 Jun 2021 00:50:36 +0530 Subject: fixed code snippet --- docs/feed.rss | 28 +++++++++++++++------- ...21-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html | 24 ++++++++++++++----- 2 files changed, 38 insertions(+), 14 deletions(-) (limited to 'docs') diff --git a/docs/feed.rss b/docs/feed.rss index 9a44450..7056029 100644 --- a/docs/feed.rss +++ b/docs/feed.rss @@ -4,8 +4,8 @@ Navan's Archive Rare Tips, Tricks and Posts https://web.navan.dev/en - Mon, 28 Jun 2021 00:47:49 -0000 - Mon, 28 Jun 2021 00:47:49 -0000 + Mon, 28 Jun 2021 00:50:20 -0000 + Mon, 28 Jun 2021 00:50:20 -0000 250 @@ -2130,14 +2130,26 @@ Otherwise, it calls the custom action.

Screenshot

-
let defaultResponses = [
-    "greetings": "Hello",
-    "banter": "no, plix no"
+
let sampleMessages = [
+    "Hey there, how is it going",
+    "hello, there",
+    "Who let the dogs out",
+    "can you tell me about the compound Geraniin",
+    "what do you know about the compound Ibuprofen",
+    "please, tell me more about the compound",
+    "please, tell me more about the molecule dihydrogen-monoxide"
 ]
 
-let customActions = [
-    "deez-drug": customAction
-]
+for sampleMessage in sampleMessages {
+    User.message = sampleMessage
+    let prediction = intentPredictor.predictedLabel(for: sampleMessage)
+
+    if (defaultResponses[prediction!] != nil) {
+        print(defaultResponses[prediction!]!)
+    } else if (customActions[prediction!] != nil) {
+        print(customActions[prediction!]!())
+    }
+}
 

Output

diff --git a/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html b/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html index e4e4d1d..228b8e4 100644 --- a/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html +++ b/docs/posts/2021-06-27-Crude-ML-AI-Powered-Chatbot-Swift.html @@ -136,14 +136,26 @@ Otherwise, it calls the custom action.

Screenshot

-
let defaultResponses = [
-    "greetings": "Hello",
-    "banter": "no, plix no"
+
let sampleMessages = [
+    "Hey there, how is it going",
+    "hello, there",
+    "Who let the dogs out",
+    "can you tell me about the compound Geraniin",
+    "what do you know about the compound Ibuprofen",
+    "please, tell me more about the compound",
+    "please, tell me more about the molecule dihydrogen-monoxide"
 ]
 
-let customActions = [
-    "deez-drug": customAction
-]
+for sampleMessage in sampleMessages {
+    User.message = sampleMessage
+    let prediction = intentPredictor.predictedLabel(for: sampleMessage)
+
+    if (defaultResponses[prediction!] != nil) {
+        print(defaultResponses[prediction!]!)
+    } else if (customActions[prediction!] != nil) {
+        print(customActions[prediction!]!())
+    }
+}
 

Output

-- cgit v1.2.3