Skip to content
DeepForgeby svx
All problems
HardNLPnlp-160

Dialogue State Slot Update

Problem

Apply dialogue state updates to a copy of state. Each update is [slot, value].

A value of 'none' removes the slot, 'dontcare' assigns that literal value, and anything else overwrites the slot. Updates apply in order, so later updates win.

Hint

Delete on none, assign otherwise, and never mutate the input dictionary.

Test cases

case 1
in: [{"food":"thai","area":"north"},[["food","sushi"],["area","none"]]]
expected: {"food":"sushi"}
case 2
in: [{"a":"1"},[["b","2"],["c","dontcare"]]]
expected: {"a":"1","b":"2","c":"dontcare"}
case 3
in: [{},[["x","none"]]]
expected: {}
case 4
in: [{"a":"1"},[]]
expected: {"a":"1"}
case 5
in: [{"a":"1"},[["a","none"],["a","2"]]]
expected: {"a":"2"}
Starter codePython
def dialogue_state_slot_update(state, updates):
    # Your code here
    pass

5 test cases · run your code against them in the editor