time_entity = next((e for e in tracker.latest_message.entities if
e['entity'] == 'time'), None)
AttributeError: 'dict' object has no attribute 'entities'
entity = tracker.latest_message['entities'].get('value')
AttributeError: 'list' object has no attribute 'get'
ent = tracker.latest_message.entities(confidence)
AttributeError: 'dict' object has no attribute 'entities'
How can get only value of entity
ent = tracker.latest_message['entities']
I want to cook noodles.
output:
('entity',
[{u'extractor': u'ner_crf',
u'confidence': 0.787280111194543,
u'end': 19,
u'value': u'noodles',
u'entity':
u'Dish',
u'start': 13
}])
opened 02:31PM - 21 Aug 18 UTC
closed 10:52AM - 21 Mar 19 UTC
Rasa Core version:rasa-core 0.9.4
Python version: 3.6.5
Operating system : u… buntu 16.04
**Issue**:
I am trying to extract the entity and the entity scores along with the intent and intent scores (which is already achieved). I am providing the code below along with the error I am facing. Please help me by identifying the error in the logic or format of the code. Thanks in advance.
The code below is "actions.py" and the intent score is retrieved along with its display. I have used the two variables (entity_label and confidence) below from "ner_crf" pipeline component since it might help me to retrieve the entity and the entity scores but I am unable to retrieve them.
key1 = tracker.latest_message.entities(entity_label)
l_confidence_1 = tracker.latest_message.entities(confidence)
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import logging
import warnings
from rasa_core import utils
from rasa_core.actions import Action
from rasa_core.agent import Agent
from rasa_core.trackers import DialogueStateTracker
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category= DeprecationWarning)
logger = logging.getLogger(__name__)
class ActionTest(Action):
def name(self):
return 'action_test'
def run(self, dispatcher, tracker, domain):
key = tracker.latest_message.intent["name"]
l_confidence = tracker.latest_message.intent["confidence"]
key1 = tracker.latest_message.entities(entity_label)
l_confidence_1 = tracker.latest_message.entities(confidence)
logger.info(key)
logger.info(l_confidence)
logger.info(key1)
logger.info(l_confidence_1)
if tracker:
print(tracker.current_state()) # or do other things
return []
It should give me the result as follows:
intent
intent score
entity
entity score
but is giving me instead as:
ERROR rasa_core.processor - name 'ent' is not defined
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/rasa_core/processor.py", line 311, in _run_action
events = action.run(dispatcher, tracker, self.domain)
File "/home/Desktop/actions.py", line 30, in run
key1 = tracker.latest_message.entities[ent.label_]
NameError: name 'ent' is not defined
In addition, if I provide
key1 = tracker.latest_message.entities["name"]
l_confidence_1 = tracker.latest_message.entities["confidence"]
it is showing the error "cannot accept strings".