Guest User

Untitled

a guest
Jan 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import logging
  2. from rasa_core.slots import Slot
  3.  
  4. logger = logging.getLogger(__name__)
  5.  
  6. # This slot was designed to hold an "object" (called a struct here). Really this slot could hold anything, because there's
  7. # not really any validation on the type of `self.value`. What relly matters is the answer to the question
  8. # "How would an object/dict translate into a feature used for machine learning?".
  9. # In this example, it's a simple feature based on whether or not there's *anything* stored in the slot. A more complex slot
  10. # may take into account the contents of the object/dict and provide a different result in `as_feature()` (and
  11. # `feature_dimensionality()` as well).
  12. class StructSlot(Slot):
  13. def __init__(self, name,
  14. initial_value=None,
  15. value_reset_delay=None):
  16. super(StructSlot, self).__init__(name, initial_value, value_reset_delay)
  17.  
  18. def as_feature(self):
  19. if self.value is not None:
  20. return [1.0]
  21. else:
  22. return [0.0]
Add Comment
Please, Sign In to add comment