OS : Ubuntu
Issue:
I am passing a text which includes from_date
and end_date
.
text : show me the data from 1/06/2018 to 4/07/2018
How to fill two slots from a single custom action?
Pipeline:
language : "en"
pipeline:
- name : "nlp_spacy"
- name: "tokenizer_whitespace"
- name: "intent_entity_featurizer_regex"
- name: "ner_crf"
- name: "ner_synonyms"
- name: "intent_featurizer_count_vectors"
- name: "intent_classifier_tensorflow_embedding"
intent_tokenization_flag: true
intent_split_symbol: "+"
- name: "ner_duckling_http"
url: "http://localhost:8000"
After passing from duckling, it returns :
{'entities': [{'additional_info': {'from': {'grain': 'day',
'value': '2018-01-06T00:00:00.000-08:00'},
'to': {'grain': 'day',
'value': '2018-04-08T00:00:00.000-07:00'},
'type': 'interval',
'values': [{'from': {'grain': 'day',
'value': '2018-01-06T00:00:00.000-08:00'},
'to': {'grain': 'day',
'value': '2018-04-08T00:00:00.000-07:00'},
'type': 'interval'}]},
'confidence': 1.0,
'end': 44,
'entity': 'time',
'extractor': 'ner_duckling_http',
'start': 17,
'text': 'from 1/06/2018 to 4/07/2018',
'value': {'from': '2018-01-06T00:00:00.000-08:00',
'to': '2018-04-08T00:00:00.000-07:00'}}],
'intent': {'confidence': 0.9576329588890076, 'name': 'data_both'},
'intent_ranking': [{'confidence': 0.9576329588890076, 'name': 'data_both'},
{'confidence': 0.09015554189682007, 'name': 'mail_n'},
{'confidence': 0.051499027758836746, 'name': 'greet'},
{'confidence': 0.0047898367047309875, 'name': 'deny'},
{'confidence': 0.0022946372628211975, 'name': 'complain'},
{'confidence': 0.0, 'name': 'affirm'},
{'confidence': 0.0, 'name': 'thanks'},
{'confidence': 0.0, 'name': 'data'},
{'confidence': 0.0, 'name': 'screenshot'},
{'confidence': 0.0, 'name': 'mail_g'}],
'text': 'show me the data from 1/06/2018 to 4/07/2018'}
Custom_Action:
class data_interval(Action):
def name(self):
return 'action_data_interval'
def run(self,dispatcher,tracker,domain):
d = tracker.latest_message.get('text')
interpreter = Interpreter.load('./models/nlu/default/retail')
a = json.dumps(interpreter.parse(d))
b = json.loads(a)
fr = b['entities'][0]['value']['from']
from_date = fr[0:10]
to_ = b['entities'][0]['value']['to']
to_date = to_[0:10]
return[SlotSet('from',from_date),SlotSet('to',to_date)]
Story :
## Story - 8
* greet
- utter_greet
* data_both
- action_listen
- action_data_interval
- slot{"from": "2019-07-01"}
- slot{"from": "2020-08-01"}
- utter_summary
- action_summary
- utter_ask