blob: f9a795262d1c7528297bf41e5572632499f744cf (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
from abc import ABCMeta
from future.utils import with_metaclass
from snips_inference_agl.pipeline.processing_unit import ProcessingUnit
from snips_inference_agl.common.abc_utils import classproperty
class IntentClassifier(with_metaclass(ABCMeta, ProcessingUnit)):
"""Abstraction which performs intent classification
A custom intent classifier must inherit this class to be used in a
:class:`.ProbabilisticIntentParser`
"""
@classproperty
def unit_name(cls): # pylint:disable=no-self-argument
return IntentClassifier.registered_name(cls)
# @abstractmethod
def get_intent(self, text, intents_filter):
"""Performs intent classification on the provided *text*
Args:
text (str): Input
intents_filter (str or list of str): When defined, it will find
the most likely intent among the list, otherwise it will use
the whole list of intents defined in the dataset
Returns:
dict or None: The most likely intent along with its probability or
*None* if no intent was found. See
:func:`.intent_classification_result` for the output format.
"""
pass
# @abstractmethod
def get_intents(self, text):
"""Performs intent classification on the provided *text* and returns
the list of intents ordered by decreasing probability
The length of the returned list is exactly the number of intents in the
dataset + 1 for the None intent
.. note::
The probabilities returned along with each intent are not
guaranteed to sum to 1.0. They should be considered as scores
between 0 and 1.
"""
pass
|