Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import logging
- from rasa_core.slots import Slot
- logger = logging.getLogger(__name__)
- # This slot was designed to hold an "object" (called a struct here). Really this slot could hold anything, because there's
- # not really any validation on the type of `self.value`. What relly matters is the answer to the question
- # "How would an object/dict translate into a feature used for machine learning?".
- # In this example, it's a simple feature based on whether or not there's *anything* stored in the slot. A more complex slot
- # may take into account the contents of the object/dict and provide a different result in `as_feature()` (and
- # `feature_dimensionality()` as well).
- class StructSlot(Slot):
- def __init__(self, name,
- initial_value=None,
- value_reset_delay=None):
- super(StructSlot, self).__init__(name, initial_value, value_reset_delay)
- def as_feature(self):
- if self.value is not None:
- return [1.0]
- else:
- return [0.0]
Add Comment
Please, Sign In to add comment