I am confused about ‘slot mapping’,in the sectionSlot Filling, the example for the restaurant bot:
def slot_mapping(self):
# type: () -> Dict[Text: Union[Text, Dict, List[Text, Dict]]]
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where the first match will be picked"""
return {"cuisine": self.from_entity(entity="cuisine",
intent="inform"),
"num_people": self.from_entity(entity="number"),
"outdoor_seating": [self.from_entity(entity="seating"),
self.from_intent(intent='affirm',
value=True),
self.from_intent(intent='deny',
value=False)],
"preferences": [self.from_text(intent='inform'),
self.from_intent(intent='deny',
value="no additional "
"preferences")],
"feedback": [self.from_entity(entity="feedback"),
self.from_text()]}
I can not understand the ‘self.from_entity’ function ,the source code of ‘from_entity’ is:
def from_entity(self,
entity, # type: Text
intent=None, # type: Optional[Union[Text, List[Text]]]
not_intent=None # type: Optional[Union[Text, List[Text]]]
):
# type: (...) -> Dict[Text: Any]
"""A dictionary for slot mapping to extract slot value from
- an extracted entity
- conditioned on
- intent if it is not None
- not_intent if it is not None,
meaning user intent should not be this intent
"""
intent, not_intent = self._list_intents(intent, not_intent)
return {"type": "from_entity", "entity": entity,
"intent": intent, "not_intent": not_intent}
According to the source code, self.from_entity(entity=“cuisine”,intent=“inform”) should return “cuisine”,not return the value of cuisine,such as chinese, swedish, If so, what is the role of the ‘from_entity’ function?what is the role of the ‘slot_mapping’ function?