Hi i am slightly new to the rasa stack and i am creating a bot that i supposed to extract some information like warning level and time to make api call to mongodb running on backend(localy).
i am able to extract predifined entities with CRF however when i want to extract time entity value from from user text in my costum action as a test, it does not work and gives me a none result. When checking the with rasa shell nlu
it works fine shows me the that duckling did extract the time. so here are my question:
1.How do i correctly extract time
from user text
-
How do i extract
from and To time fields i.e start time and end time
-
i would also like to know how to
repeat a message utterance
with a loop since mongodb return a cursor on which i need to loop.
domain_snippet:
intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- new_files
- find_errors_simple
- find_errorsInterval
- find_newCount
- mark_has_read
- inform
- thank
entities:
- warning_level
- unchecked_log
- checked_log
- mark_read
- newError_report
- time_interval
##if slot has same name as entity it's value will be same the value as the entity, after the feature extraction
slots:
warning_level:
type: text
savedInfo:
type: unfeaturized
actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
- utter_iamabot
- ActionSearchDB
- utter_no_problem
- action_infoCheck ##
- utter_reEnterInfo ##
#- action_out_of_scope
config pipeline:
language: en
pipeline: #supervised_embeddings
- name: "WhitespaceTokenizer"
- name: "RegexFeaturizer"
- name: "CRFEntityExtractor"
- name: "EntitySynonymMapper" #mapp synonyms to wanted entity
- name: "CountVectorsFeaturizer"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"
- name: "DucklingHTTPExtractor"
url: "http://192.168.99.101:8000"
dimensions: ["time"]
locale: 'en_UK'
timezone: "UK/London"
action test sample:
import pymongo
#from __future__ import absolute_import
#from __future__ import division
#from __future__ import unicode_literals
from typing import Any, Text, Dict, List
from pymongo.database import Database
from pymongo import MongoClient
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import SlotSet
from rasa_sdk.form import FormAction
#import MongoClient
import json
import datetime
class ActionInfoCheck(Action):
def name(self) -> Text:
return "action_infoCheck"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
warningLvl = tracker.get_slot("warning_level")
time = tracker.get_slot("time")
savedInfo = "I saved this for test purposes"
dispatcher.utter_message("Is this the information you entered? {}:{}".format(warningLvl, time))
return[SlotSet("savedInfo", savedInfo)]#slots added here have to be reflected inside stories.md under the calling action, and added to the domain
#under slots
and finally rasa nlu output:
find errors between saturday at 12:34 and sunday 23:05
{
"intent": {
"name": "find_errorsInterval",
"confidence": 0.9264986515045166
},
"entities": [
{
"start": 5,
"end": 11,
"value": "error",
"entity": "warning_level",
"confidence": 0.9674813313181307,
"extractor": "CRFEntityExtractor",
"processors": [
"EntitySynonymMapper"
]
},
{
"start": 12,
"end": 19,
"value": "between",
"entity": "time_interval",
"confidence": 0.9047831394511845,
"extractor": "CRFEntityExtractor"
},
{
"start": 12,
"end": 54,
"text": "between saturday at 12:34 and sunday 23:05",
"value": {
"to": "2020-03-15T23:06:00.000+00:00",
"from": "2020-03-14T00:34:00.000+00:00"
},
"confidence": 1.0,
"additional_info": {
"values": [
{
"to": {
"value": "2020-03-15T23:06:00.000+00:00",
"grain": "minute"
},
"from": {
"value": "2020-03-14T00:34:00.000+00:00",
"grain": "minute"
},
"type": "interval"
},
{
"to": {
"value": "2020-03-15T23:06:00.000+00:00",
"grain": "minute"
},
"from": {
"value": "2020-03-14T12:34:00.000+00:00",
"grain": "minute"
},
"type": "interval"
},
{
"to": {
"value": "2020-03-22T23:06:00.000+00:00",
"grain": "minute"
},
"from": {
"value": "2020-03-21T00:34:00.000+00:00",
"grain": "minute"
},
"type": "interval"
}
],
"to": {
"value": "2020-03-15T23:06:00.000+00:00",
"grain": "minute"
},
"from": {
"value": "2020-03-14T00:34:00.000+00:00",
"grain": "minute"
},
"type": "interval"
},
"entity": "time",
"extractor": "DucklingHTTPExtractor"
}
],
"intent_ranking": [
{
"name": "find_errorsInterval",
"confidence": 0.9264986515045166
},
{
"name": "mood_unhappy",
"confidence": 0.021978706121444702
},
{
"name": "thank",
"confidence": 0.011257205158472061
},
{
"name": "affirm",
"confidence": 0.009684749878942966
},
{
"name": "mood_great",
"confidence": 0.009016020223498344
},
{
"name": "mark_has_read",
"confidence": 0.004983078688383102
},
{
"name": "deny",
"confidence": 0.004659407306462526
},
{
"name": "greet",
"confidence": 0.004530702251940966
},
{
"name": "bot_challenge",
"confidence": 0.0034581569489091635
},
{
"name": "goodbye",
"confidence": 0.0023854069877415895
}
],
"text": "find errors between saturday at 12:34 and sunday 23:05"
}