diff options
Diffstat (limited to 'snips_inference_agl/slot_filler/slot_filler.py')
-rw-r--r-- | snips_inference_agl/slot_filler/slot_filler.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/snips_inference_agl/slot_filler/slot_filler.py b/snips_inference_agl/slot_filler/slot_filler.py new file mode 100644 index 0000000..a1fc937 --- /dev/null +++ b/snips_inference_agl/slot_filler/slot_filler.py @@ -0,0 +1,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 |