Zaktualizuj 'dialogue_system.py'
fix recognition of seat,row,quantity and reaction to answers
This commit is contained in:
parent
c447c27731
commit
d4e143c2ec
@ -30,7 +30,7 @@ def main():
|
||||
nlu = NLU()
|
||||
dst = DST()
|
||||
# dp = DP()
|
||||
nlg = NLG()
|
||||
nlg = NLG(dst)
|
||||
|
||||
nlu.train_slot_model('data/train+test-pl.conllu', 'data/train+test-pl.conllu')
|
||||
nlu.train_intent_model('data/NLU_data_intent')
|
||||
@ -56,14 +56,106 @@ def main():
|
||||
slots = nlu.predict_slots(user_input)
|
||||
intent = nlu.predict_intent(user_input)
|
||||
formatted_prediction = format_prediction(slots, intent)
|
||||
#print(formatted_prediction)
|
||||
for slot in formatted_prediction:
|
||||
if len(formatted_prediction)<2:
|
||||
if dst.state['system_action'][-1] != slot:
|
||||
formatted_prediction.remove(slot)
|
||||
formatted_prediction.append([slot[0],slot[1],dst.state['system_action'][-1][0][2],slot[3]])
|
||||
if slot[2]=='seat':
|
||||
if ',' in slot[3]:
|
||||
seat,row = slot[3].split(',')
|
||||
formatted_prediction.remove(['inform', 'Cinema', 'seat', slot[3]])
|
||||
formatted_prediction.append(['inform', 'Cinema', 'seat', seat])
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', f' {row}'])
|
||||
if 'rzęd' in user_input_lr:
|
||||
formatted_prediction_tmp = formatted_prediction.copy()
|
||||
user_input_splited = user_input_lr.split()
|
||||
for slots in formatted_prediction:
|
||||
if slots[2] =='row' or slots[2]=='seat' or slots[2] =='quantity':
|
||||
formatted_prediction_tmp.remove(slots)
|
||||
formatted_prediction = formatted_prediction_tmp.copy()
|
||||
if 'miejsc' not in user_input_lr and 'bilet' not in user_input_lr:
|
||||
for i in range(len(user_input_splited)-1):
|
||||
if 'rzęd' in user_input_splited[i]:
|
||||
try:
|
||||
if isinstance(int(user_input_splited[i+1]),int)and i==0:
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
elif 'miejsc' in user_input_lr and 'bilet' not in user_input_lr:
|
||||
for i in range(len(user_input_splited)-1):
|
||||
print(user_input_splited[i],user_input_splited[i+1])
|
||||
if 'rzęd' in user_input_splited[i]:
|
||||
try:
|
||||
if isinstance(int(user_input_splited[i+1]),int)and i==0:
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
if 'miejsc' in user_input_splited[i]:
|
||||
try:
|
||||
if i==0 and isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'seat', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'seat', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'seat', user_input_splited[i+1]])
|
||||
elif 'miejsc' not in user_input_lr and 'bilet' in user_input_lr:
|
||||
for i in range(len(user_input_splited)-1):
|
||||
print(user_input_splited[i],user_input_splited[i+1])
|
||||
if 'rzęd' in user_input_splited[i]:
|
||||
try:
|
||||
if isinstance(int(user_input_splited[i+1]),int)and i==0:
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
if 'miejsc' in user_input_splited[i]:
|
||||
try:
|
||||
if i==0 and isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'quantity', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'quantity', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'quantity', user_input_splited[i+1]])
|
||||
elif 'miejsc' in user_input_lr and 'bilet' in user_input_lr:
|
||||
for i in range(len(user_input_splited)-1):
|
||||
if 'rzęd' in user_input_splited[i]:
|
||||
try:
|
||||
if isinstance(int(user_input_splited[i+1]),int)and i==0:
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'row', user_input_splited[i+1]])
|
||||
if 'miejsc' in user_input_splited[i]:
|
||||
try:
|
||||
if isinstance(int(user_input_splited[i+1]),int) and i==0:
|
||||
formatted_prediction.append(['inform', 'Cinema', 'seat', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'seat', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'seat', user_input_splited[i+1]])
|
||||
if 'bilet' in user_input_splited[i]:
|
||||
try:
|
||||
if isinstance(int(user_input_splited[i+1]),int)and i==0:
|
||||
formatted_prediction.append(['inform', 'Cinema', 'quantity', user_input_splited[i+1]])
|
||||
elif isinstance(int(user_input_splited[i-1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'quantity', user_input_splited[i-1]])
|
||||
except:
|
||||
if isinstance(int(user_input_splited[i+1]),int):
|
||||
formatted_prediction.append(['inform', 'Cinema', 'quantity', user_input_splited[i+1]])
|
||||
|
||||
|
||||
if user_input_lr == '/pomoc':
|
||||
@ -80,7 +172,6 @@ def main():
|
||||
dst = DST()
|
||||
# dp = DP() ?
|
||||
print('Witaj, jestem Usher - system do rezerwacji biletów kinowych. W czym mogę Ci pomóc?')
|
||||
|
||||
elif 'rezerw' in user_input_lr:
|
||||
if 'anulo' in user_input_lr:
|
||||
flag=False
|
||||
@ -145,7 +236,8 @@ def main():
|
||||
if not flag:
|
||||
print(nlg.update([['cinema','offer','closestscreening','']]))
|
||||
|
||||
elif (('czy' or 'jakie' or 'które') and ('dostęp' or 'woln' or 'zajęt') and 'miejsc') in user_input_lr:
|
||||
elif ('czy' or 'jakie' or 'które') and ('dostęp' or 'woln' or 'zajęt') in user_input_lr:
|
||||
if 'miejsce' in user_input_lr:
|
||||
dst.update([['offer', 'Cinema', 'task', 'show_seats']])
|
||||
flag=False
|
||||
for slot in slots:
|
||||
@ -191,5 +283,3 @@ def main():
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user