nlu.annotation.rule_based_annotator¶
This file contains a class which can be used to annotate slot values in the user utterance based on rules and keyword matching.
Module Contents¶
Classes¶
This class is used to annotate slot values in the user utterance. |
- class nlu.annotation.rule_based_annotator.RBAnnotator(process_value: Callable[[str], str], lemmatize_value: Callable[[str], str], slot_values: Dict[str, Any])¶
Bases:
moviebot.nlu.annotation.slot_annotator.SlotAnnotatorThis class is used to annotate slot values in the user utterance.
- slot_annotation(slot: str, user_utterance: moviebot.core.utterance.utterance.UserUtterance) List[moviebot.nlu.annotation.item_constraint.ItemConstraint]¶
Annotates user utterance for specified slot.
Returns empty list if there is no annotation or the annotator is not defined for the slot.
- Parameters
slot – Slot name.
utterance – User utterance.
- Returns
List of item constraints.
- find_in_raw_utterance(raw_utterance: str, gram: str, ngram_size: int) str¶
Finds the ngram in the raw utterance.
If the ngram is found in the utterance it is returned with removed punctuation.
- Parameters
raw_utterance – The raw utterance.
gram – The ngram to be found in the raw_utterance.
ngram_size – The size of the n-gram.
- Returns
The ngram found in the utterance.