diff options
author | 2023-10-22 21:06:23 +0500 | |
---|---|---|
committer | 2023-10-23 14:38:13 +0000 | |
commit | 697a1adce1e463079e640b55d6386cf82d7bd6bc (patch) | |
tree | 86e299cc7fe12b10c2e549f640924b61c7d07a95 /snips_inference_agl/intent_classifier/intent_classifier.py | |
parent | 97029ab8141e654a170a2282106f854037da294f (diff) |
Add Snips Inference Module
Add slightly modified version of the original Snips NLU
library. This module adds support for Python upto version
3.10.
Bug-AGL: SPEC-4856
Signed-off-by: Malik Talha <talhamalik727x@gmail.com>
Change-Id: I6d7e9eb181e6ff4aed9b6291027877ccb9f0d846
Diffstat (limited to 'snips_inference_agl/intent_classifier/intent_classifier.py')
-rw-r--r-- | snips_inference_agl/intent_classifier/intent_classifier.py | 51 |
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 |