Added state facts
This commit is contained in:
parent
4abdf95b9a
commit
dcf6931529
@ -4,6 +4,11 @@ dialogue_state = {
|
||||
# topics will be an array of dicts structured similar to this
|
||||
# {'act': 'notifications', 'slots': [('time_when', None), ('liczba', ''), ('timeunit', None)]}
|
||||
'topics': [],
|
||||
# facts is a dict of contextual data such as selected repo and a timeframe
|
||||
'facts': {
|
||||
'repo' : '',
|
||||
'time': ''
|
||||
},
|
||||
'counter': 0
|
||||
}
|
||||
|
||||
@ -36,6 +41,18 @@ def append_or_merge_frame(frame, dialogue_state):
|
||||
dialogue_state['topics'].append(frame)
|
||||
|
||||
|
||||
def update_facts_if_needed(slot):
|
||||
global dialogue_state
|
||||
|
||||
if slot[1] is None or slot[1] == '':
|
||||
return
|
||||
|
||||
if slot[0] == 'repo':
|
||||
dialogue_state['facts']['repo'] = slot[1]
|
||||
elif slot[0] == 'time':
|
||||
dialogue_state['facts']['time'] = slot[1]
|
||||
|
||||
|
||||
def append_or_merge_slots(frame_slots, state_slots):
|
||||
"""
|
||||
This function expects both parameters to be an array
|
||||
@ -45,6 +62,7 @@ def append_or_merge_slots(frame_slots, state_slots):
|
||||
for frame_slot in frame_slots:
|
||||
merged = False
|
||||
for i in range(len(state_slots)):
|
||||
update_facts_if_needed(frame_slot[i])
|
||||
if state_slots[i][0] == frame_slot[0]:
|
||||
merged = True
|
||||
# Do not merge empty incomming slots
|
||||
@ -64,3 +82,5 @@ def reset_state_if_needed(frame, dialogue_state):
|
||||
if frame['act'] == "hello" or frame['act'] == "bye":
|
||||
dialogue_state['topics'] = []
|
||||
dialogue_state['counter'] = 0
|
||||
# should we reset 'facts' aswell?
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user