BeWe11 / rasa_composite_entities

A Rasa NLU component for composite entities.
MIT License
29 stars 10 forks source link

Package misses out custom entities but picks the duckling entity #18

Open NomanSaleem4 opened 4 years ago

NomanSaleem4 commented 4 years ago

I have this pattern

{
    "composite_entities": [
        {
            "name": "order.salads_composite",
            "patterns": ["@quantity @salads"]
        }
    ]
}

but the problem i am facing here is, when i input "i want to order 1 greek salad " bot extracts three entities quantity salads and number as [{'entity': 'quantity', 'start': 16, 'end': 17, 'confidence_entity': 0.9876763780464889, 'value': '1', 'extractor': 'CRFEntityExtractor'}, {'start': 16, 'end': 17, 'text': '1', 'value': 1, 'confidence': 1.0, 'additional_info': {'value': 1, 'type': 'value'}, 'entity': 'number', 'extractor': 'DucklingHTTPExtractor'}, {'entity': 'salads', 'start': 18, 'end': 29, 'confidence_entity': 0.9803940941544417, 'value': 'Greek Salad', 'extractor': 'CRFEntityExtractor', 'processors': ['EntitySynonymMapper']}]

Here why does the package does not extract composite order.salads_composite containing [quantity and salads]? It should have extracted it.

But on the other side when i included another pattern that is "patterns": ["@number @salads"] its extracted order.salads_composite composite(number is the duckling entity). Why its showing this behavior? Eagerly waiting for your response and the fix if required . Thank you so much.

BeWe11 commented 4 years ago

Gonna take a look at this today @NomanSaleem4

BeWe11 commented 4 years ago

Ok, you found an edge case where overlapping entities override each other during the pattern search. In your example, the duckling number comes after the "quantity" entity but starts at the same position "16", therefore the "quantity" entity cannot be found when patterns are searched. If the duckling number would be the first item in your entity list, the pattern would have been found, as the "quantity" entity would then override the duckling number.

The (general) solution to this problem is not obvious to me, I'll have to think about this.

NomanSaleem4 commented 4 years ago

Hmm i got you. A bit tricky it is

NomanSaleem4 commented 4 years ago

Did you face the similar problem in version 0.4.5 or it was not there?

BeWe11 commented 4 years ago

The problem arises out of the core functionality of this component, so it should have been there from the start.

NomanSaleem4 commented 4 years ago

Hmm ok.