aboutsummaryrefslogtreecommitdiffstats
path: root/snips_inference_agl/intent_classifier/intent_classifier.py
diff options
context:
space:
mode:
Diffstat (limited to 'snips_inference_agl/intent_classifier/intent_classifier.py')
-rw-r--r--snips_inference_agl/intent_classifier/intent_classifier.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/snips_inference_agl/intent_classifier/intent_classifier.py b/snips_inference_agl/intent_classifier/intent_classifier.py
new file mode 100644
index 0000000..f9a7952
--- /dev/null
+++ b/snips_inference_agl/intent_classifier/intent_classifier.py
@@ -0,0 +1,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