Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to filter the detection of the intent by the entity type? #1353

Closed
ghost opened this issue Aug 22, 2023 · 1 comment
Closed

Comments

@ghost
Copy link

ghost commented Aug 22, 2023

I'm experimenting with this great library.

And I have the following question:
When I have two intents that are very similar in their syntax in the utterances, where they would differ by the type of intent (date, month, string, etc...).

it is possible to give more weight to an intent taking into account the type of entity?
Or simply that it should not be taken into account if the detected entity was not a date type, for example?

Let me give a practical example:
1º Intent : pedidosCliente
2º Intent : pedidosFechas ( this intent should only take it into account when your entity is of type date (or month for example) )

A corpus:
{
"name": "Hanna Corpus",
"locale": "es-ES",
"entities": {

"entityCliente": {
  "trim": [
    {
      "position": "after",
      "words": [ "cliente", "de" ]
    }
  ]
},

"entityFechaIni": {
  "trim": [
    {
      "position": "betweenLast",
      "leftWords": [ "de" ],
      "rightWords": [ "a" ]
    },
    {
      "position": "betweenLast",
      "leftWords": [ "del" ],
      "rightWords": [ "a" ]
    },
    {
      "position": "betweenLast",
      "leftWords": [ "de" ],
      "rightWords": [ "hasta" ]
    },
    {
      "position": "betweenLast",
      "leftWords": [ "del" ],
      "rightWords": [ "hasta" ]
    },
    {
      "position": "betweenLast",
      "leftWords": [ "fechas" ],
      "rightWords": [ "y" ]
    },

    {
      "position": "afterLast",
      "words": [ "de" ]
    },
    {
      "position": "afterLast",
      "words": [ "del" ]
    },
    {
      "position": "afterLast",
      "words": [ "fechas" ]
    }
  ]
},
"entityFechaFin": {
  "trim": [
    {
      "position": "betweenLast",
      "leftWords": [ "a", "hasta", "y" ],
      "rightWords": [ "de" ]
    },
    {
      "position": "afterLast",
      "words": [ "a", "hasta", "y" ]
    }
  ]
}

},
"data": [

{
  "intent": "pedidosCliente",
  "utterances": [
"Quiero ver los pedidos de @entityCliente",
    "Quiero ver los pedidos del cliente @entityCliente",
"Muestra los pedidos de @entityCliente",
    "Muestrame los pedidos de @entityCliente"
  ],
  "answers": [
    "Ok, te muestro los pedidos del cliente {{entityCliente}}"
  ]
},
{
  "intent": "pedidosFechas",
  "utterances": [
"Quiero ver los pedidos de @FechaIni",
    "Quiero ver los pedidos de @FechaIni a @FechaFin",
"Muestra los pedidos de @FechaIni",
    "Muestrame los pedidos de @FechaIni"
  ],
  "answers": [
    "Ok, te muestro los pedidos desde {{entityFechaIni}} hasta {{entityFechaFin}}"
  ]
}

]
}

The result of process "Quiero ver los pedidos de Pepe":
{
"locale": "es",
"utterance": "Quiero ver los pedidos de Pepe",
"languageGuessed": false,
"localeIso2": "es",
"language": "Spanish",
"nluAnswer": {
"classifications": [
{
"intent": "pedidosFechas",
"score": 0.5032182311986605
},
{
"intent": "pedidosCliente",
"score": 0.49678176880133956
}
]
},
"classifications": [
{
"intent": "pedidosFechas",
"score": 0.5032182311986605
},
{
"intent": "pedidosCliente",
"score": 0.49678176880133956
}
],
"intent": "pedidosFechas",
"score": 0.5032182311986605,
"domain": "default",
.....
}

As you can see, it detects the intent "pedidosFechas" when the correct one should be the intent "pedidosCliente".
On the contrary, if the request processed were "Quiero ver los pedidos de Junio", if it should detect as main intent "pedidosFechas"

Any idea how to get it?

The way could be by "slot filing"?
Intent : pedidosFechas
"slotFilling": {
"FechaIni": {
"mandatory": true,
----> "type": "date" ----> Something similar
},

Thank you so much.

@ghost
Copy link
Author

ghost commented Aug 26, 2023

sorry I'm an ignorant newbie xD, the corpus was wrong, by default it already does it correctly
Corrects utterances:

"data": [

{
  "intent": "pedidosCliente",
  "utterances": [
"Quiero ver los pedidos de Paco",
    "Quiero ver los pedidos del cliente Alberto",
"Muestra los pedidos de Carlos",
    "Muestrame los pedidos de Mario"
  ],
  "answers": [
    "Ok, te muestro los pedidos del cliente {{entityCliente}}"
  ]
},

{
  "intent": "pedidosFechas",
  "utterances": [
"Quiero ver los pedidos de Enero",
"Quiero ver los pedidos de febrero",
"Quiero ver los pedidos de marzo",
"Quiero ver los pedidos de abril",
"Quiero ver los pedidos de mayo",
"Quiero ver los pedidos de junio",
    "Quiero ver los pedidos de Enero a febrero",
"Muestra los pedidos de enero",
    "Muestrame los pedidos de enero"
  ],
  "answers": [
    "Ok, te muestro los pedidos desde {{entityFechaIni}} hasta {{entityFechaFin}}",
"Ok, te muestro los pedidos de {{entityFechaIni}}"
  ]
}

]

I close the thread thanks

@ghost ghost closed this as completed Aug 26, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants