blob: a1fc9370102dfcaaad3a23922a5ecca106aace02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
from abc import abstractmethod, ABCMeta
from future.utils import with_metaclass
from snips_inference_agl.common.abc_utils import classproperty
from snips_inference_agl.pipeline.processing_unit import ProcessingUnit
class SlotFiller(with_metaclass(ABCMeta, ProcessingUnit)):
"""Abstraction which performs slot filling
A custom slot filler must inherit this class to be used in a
:class:`.ProbabilisticIntentParser`
"""
@classproperty
def unit_name(cls): # pylint:disable=no-self-argument
return SlotFiller.registered_name(cls)
@abstractmethod
def fit(self, dataset, intent):
"""Fit the slot filler with a valid Snips dataset"""
pass
@abstractmethod
def get_slots(self, text):
"""Performs slot extraction (slot filling) on the provided *text*
Returns:
list of dict: The list of extracted slots. See
:func:`.unresolved_slot` for the output format of a slot
"""
pass
|