snipsco / snips-nlu

Snips Python library to extract meaning from text
https://snips-nlu.readthedocs.io
Apache License 2.0
3.88k stars 515 forks source link

No TimeInterval slot for "next hour" #884

Open tadly opened 3 years ago

tadly commented 3 years ago

Describe the bug

Using "next hour" in a sentence does not return a TimeInterval slot like "next one hour" does. This is true when using snips/datetime or snips/timePeriod.

The following example only focuses on snips/timePeriod though.

To Reproduce

import json

from snips_nlu import SnipsNLUEngine, load_resources

def test_snips(phrase):
    data = {
        'language': 'en',
        'entities': {
            'snips/timePeriod': {}
        },
        'intents': {
            'weather.will_rain': {
                'utterances': [{
                    'data': [{
                        'text': 'Will it rain in the '
                    }, {
                        'text': 'next two hours',
                        'slot_name': 'date_time',
                        'entity': 'snips/timePeriod'
                    }]
                }]
            },
            'weather.will_snow': {
                'utterances': [{
                    'data': [{
                        'text': 'Will it snow in the '
                    }, {
                        'text': 'next hour',
                        'slot_name': 'date_time',
                        'entity': 'snips/timePeriod'
                    }]
                }]
            }
        },
    }

    engine = SnipsNLUEngine(resources=load_resources('snips_nlu_en'))
    engine.fit(data)

    parsing = engine.parse(phrase)
    print(json.dumps(parsing, indent=2))

# Works as expected
test_snips('Will it rain in the next one hour?')

# Doesn't work
test_snips('Will it snow in the next hour?')

Expected behavior

I would expect a TimeInterval slot just like I get for ...in the next one hour?

Environment: