Rasa NLU - classification by position

Hi I would like to create NLU model in the following way. not sure how to approach this . will be happy to get some help

i will use these intents (custom components ):

  1. if_then_,[],[] #intent name is if_then_ with 2 inputs
  2. smaller,[],[] #intent name is smaller with 2 inputs : (<)
  3. calories_,[] #intent name is calories_ function with 1 input (name of the fruit, string) and returns the number of calories(int)
  4. eat_,[] #intent name is eat_ function with 1 input (recommended fruit) (string)

user input: “If the number of calories in an apple is less than the number of calories in an orange, then eat an apple”

wanted output: if_then_,[smaller, [calories_,[‘apple’])],[calories_,[‘orange’]]],[eat_,[‘apple’]]

thanks :slight_smile:

can anyone help please?

@adamid I guess, you can try to use entities for your use case (Entity Extraction).

So, for example, you could annotate the sentence in the following way:

## intent: if-then
 - If the number of [calories in an apple](calories) is [less than](comparator) the number of [calories in an orange](calories), then [eat an apple](eat)

So, you would have the overall intent specifying the sentence as an “if-then” sentence and three entities, one for calories, one comparison entity, and one entity for eat.

In the custom action (Actions), that would follow the “if-then” utterance of a user, you could extract those entities and call a function to retrieve the actual calories of the apple and orange.