Hi, Currently want to check on how can I map a entity which is extracted and map it to a value? For example,
I have different types of pizzas which I have identified them as an intent and categorised them under pizza as shown in nlu.yml :
-intent: pizza_type
examples: |
-
- [cheese pizza](pizza)
-
- [chicken pizza](pizza)
-
- [seafood pizza](pizza)
-
- [super supreme pizza](pizza)
In the actions.py file I map each pizza to a price using a dict as shown:
pizza_prices= { “cheese pizza”:"$12 per pizza", “chicken pizza”: “$15”, “seafood pizza”: “$16”, “super supreme pizza”: “$18” }
class ActionShowPrice(Action):
def name(self) -> Text:
return "action_show_price"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
pizza= tracker.get_slot("pizza")
price= pizza_price.get(pizza.lower())
if price is None:
output = "Sorry could not find"
else:
output=f"The detail are as follows:\n -Price: {pizza.upper()}\n Price: {price}"
dispatcher.utter_message(text=output)
return []
So my issue now is :
- If user inputs “cheese pizza” the entity is correctly identified and the output “$12 per pizza” is shown. However, if user inputs “cheese pizzas” or “cheeze pizza”(any other form of typo) the entity is still correctly identified as pizza but I am unable to find a solution to map it exactly back to the dictionary’s value. A simple but not elegant fix is to include different versions of the same phrase in the dictionary to map it to “$12 per pizza”. Thus, I would like to know if there are any methods avaliable to fix this mapping a entity to its desired value issue ?