Skip to content
Muhittin edited this page Nov 8, 2018 · 2 revisions

Welcome to the rapydscript-ng wiki!

“fulfillmentState': fulfillment_state, 'message': message } }   return response     def delegate(session_attributes, slots): return { 'sessionAttributes': session_attributes, 'dialogAction': { 'type': 'Delegate', 'slots': slots } }    

--- Helper Functions ---

    def safe_int(n): """ Safely convert n value to int. """ if n is not None: return int(n) return n     def try_ex(func): """ Call passed in function in try block. If KeyError is encountered return None. This function is intended to be used to safely access dictionary.   Note that this function would have negative impact on performance. """   try: return func() except KeyError: return None     def generate_car_price(location, days, age, car_type): """ Generates a number within a reasonable range that might be expected for a flight. The price is fixed for a given pair of locations. """   car_types = ['economy', 'standard', 'midsize', 'full size', 'minivan', 'luxury'] base_location_cost = 0 for i in range(len(location)): base_location_cost += ord(location.lower()[i]) - 97   age_multiplier = 1.10 if age < 25 else 1 # Select economy is car_type is not found if car_type not in car_types: car_type = car_types[0]   return days * ((100 + base_location_cost) + ((car_types.index(car_type) * 50) * age_multiplier))     def generate_hotel_price(location, nights, room_type): """ Generates a number within a reasonable range that might be expected for a hotel. The price is fixed for a pair of location and roomType. """   room_types = ['queen', 'king', 'deluxe'] cost_of_living = 0[…]”

Clone this wiki locally