Compare commits
2 Commits
09157ce36f
...
71f525ec07
Author | SHA1 | Date | |
---|---|---|---|
71f525ec07 | |||
312225b307 |
@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"address": null,
|
"addr": null,
|
||||||
"order-complete": false,
|
"confirm": [
|
||||||
|
"true",
|
||||||
|
"false"
|
||||||
|
],
|
||||||
"dough": ["thick"],
|
"dough": ["thick"],
|
||||||
"drink": ["pepsi", "cola", "water"],
|
"drink": ["pepsi", "cola", "water"],
|
||||||
"food": ["pizza"],
|
"food": ["pizza"],
|
||||||
|
@ -2,7 +2,7 @@ kto treść akt
|
|||||||
user Dzień dobry, chciałbym zamówić pizzę. request(menu)
|
user Dzień dobry, chciałbym zamówić pizzę. request(menu)
|
||||||
system Dzień dobry,\nOferujemy pizze:\nmargharita\ncapri\nhawajska\nbarcelona\ntuna\nWystępują w rozmiarach M (31cm), L (41cm) , XL (52cm) inform(menu)
|
system Dzień dobry,\nOferujemy pizze:\nmargharita\ncapri\nhawajska\nbarcelona\ntuna\nWystępują w rozmiarach M (31cm), L (41cm) , XL (52cm) inform(menu)
|
||||||
user jaka to jest pizza barcelona? request(barcelona)
|
user jaka to jest pizza barcelona? request(barcelona)
|
||||||
system Pizza barcelona posiada: pomidory, cebulę i szynkę. inform(pizza=barcelona)
|
system Pizza barcelona posiada: pomidory, cebulę i szynkę. inform(pizza.info=barcelona)
|
||||||
user to poproszę inform(pizza=barcelona)
|
user to poproszę inform(pizza=barcelona)
|
||||||
system Rozumiem.\nCałość zamówienia to:\npizza barcelona L (szynka parmeńska) - 45ł\nPotwierdza Pan zamówienie? inform(pizza=barcelona,size=l,price=45)
|
system Rozumiem.\nCałość zamówienia to:\npizza barcelona L (szynka parmeńska) - 45ł\nPotwierdza Pan zamówienie? inform(pizza=barcelona,size=l,price=45)
|
||||||
user tak, odbiorę na miejscu inform(collection-method=pickup)
|
user tak, odbiorę na miejscu inform(collection-method=pickup)
|
||||||
|
|
@ -4,7 +4,7 @@ system Dzień dobry. Jestem wirtualnym asystentem restauracji 'pizzeria'.\nOferu
|
|||||||
user Z czym jest pizza barcelona? request(barcelona)
|
user Z czym jest pizza barcelona? request(barcelona)
|
||||||
system Pizza barcelona posiada: pomidory, cebulę i szynkę. inform(pizza=barcelona,ingredient=tomato,ingredient=onion,ingredient=ham)
|
system Pizza barcelona posiada: pomidory, cebulę i szynkę. inform(pizza=barcelona,ingredient=tomato,ingredient=onion,ingredient=ham)
|
||||||
user Jakie dodatki można dodać do tej pizzy? request(additional_ingredient)
|
user Jakie dodatki można dodać do tej pizzy? request(additional_ingredient)
|
||||||
system Do każdej pizzy istnieje ten sam zestaw dodatków są to: szynka, kawałki kurczaka, papryczka jalapeno, czosnek, karczoch, pomidor, papryka czerwona, ser, cebula, mięta inform(additional_ingredient)
|
system Do każdej pizzy istnieje ten sam zestaw dodatków są to: szynka, kawałki kurczaka, papryczka jalapeno, czosnek, karczoch, pomidor, papryka czerwona, ser, cebula, mięta inform(additional_ingredient.info)
|
||||||
user To ja chętnie zamówię pizzę barcelona z dodatkiem świeżej mięty request(pizza=barcelona,pizza.ingredient=mint)
|
user To ja chętnie zamówię pizzę barcelona z dodatkiem świeżej mięty request(pizza=barcelona,pizza.ingredient=mint)
|
||||||
system Życzy Pan sobie do tego jakiś napój? offer(drink)
|
system Życzy Pan sobie do tego jakiś napój? offer(drink)
|
||||||
user A jakie so? request(drink)
|
user A jakie so? request(drink)
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
flair==0.13.1
|
flair==0.13.1
|
||||||
conllu==4.5.3
|
conllu==4.5.3
|
||||||
pandas==1.5.3
|
pandas==1.5.3
|
||||||
torch==2.3.0
|
|
||||||
convlab==3.0.2a0
|
|
||||||
numpy==1.24.4
|
numpy==1.24.4
|
||||||
|
torch==2.3.0
|
||||||
fuzzywuzzy==0.18.0
|
fuzzywuzzy==0.18.0
|
@ -18,10 +18,10 @@ while True:
|
|||||||
# print(frame)
|
# print(frame)
|
||||||
|
|
||||||
# DSM
|
# DSM
|
||||||
monitor.update(frame)
|
# monitor.append(frame)
|
||||||
|
|
||||||
# DP
|
# DP
|
||||||
# print(dialog_policy.next_dialogue_act(monitor.read()).act)
|
# print(dialog_policy.next_dialogue_act(monitor.get_all()).act)
|
||||||
|
|
||||||
# NLG
|
# NLG
|
||||||
act, slots = parse_frame(frame)
|
act, slots = parse_frame(frame)
|
||||||
|
@ -1,60 +1,14 @@
|
|||||||
from src.model.frame import Frame
|
from model.frame import Frame
|
||||||
from convlab.dst.dst import DST
|
|
||||||
import json
|
|
||||||
import copy
|
|
||||||
|
|
||||||
|
|
||||||
def normalize(value):
|
class DialogStateMonitor:
|
||||||
value = value.lower()
|
dialog = []
|
||||||
return ' '.join(value.split())
|
|
||||||
|
|
||||||
|
def append(self, frame: Frame):
|
||||||
|
self.dialog.append(frame)
|
||||||
|
|
||||||
class DialogStateMonitor(DST):
|
def get_all(self) -> [Frame]:
|
||||||
def __init__(self, initial_state_file: str = '../attributes.json'):
|
return self.dialog
|
||||||
DST.__init__(self)
|
|
||||||
with open(initial_state_file) as file:
|
|
||||||
self.__initial_state = json.load(file)
|
|
||||||
self.__memory = copy.deepcopy(self.__initial_state)
|
|
||||||
|
|
||||||
# def __access_memory__(self, path: str) -> str | int | float | None:
|
def get_last(self) -> Frame:
|
||||||
# result = self.state['memory']
|
return self.dialog[len(self.dialog) - 1]
|
||||||
# for segment in path.split('.'):
|
|
||||||
# if segment not in result:
|
|
||||||
# return None
|
|
||||||
# result = result[segment]
|
|
||||||
# return result
|
|
||||||
|
|
||||||
def update(self, frame: Frame):
|
|
||||||
if frame.source != 'user':
|
|
||||||
return
|
|
||||||
if frame.act == 'inform/order':
|
|
||||||
new_order = dict()
|
|
||||||
for slot in frame.slots:
|
|
||||||
new_order[slot.name] = normalize(slot.value)
|
|
||||||
self.__memory['order'].append(new_order)
|
|
||||||
elif frame.act == 'inform/address':
|
|
||||||
for slot in frame.slots:
|
|
||||||
self.__memory['address'][slot.name] = normalize(slot.value)
|
|
||||||
elif frame.act == 'inform/phone':
|
|
||||||
for slot in frame.slots:
|
|
||||||
self.__memory['phone'][slot.name] = normalize(slot.value)
|
|
||||||
elif frame.act == 'inform/order-complete':
|
|
||||||
self.__memory['order-complete'] = True
|
|
||||||
elif frame.act == 'inform/delivery':
|
|
||||||
for slot in frame.slots:
|
|
||||||
self.__memory['delivery'][slot.name] = normalize(slot.value)
|
|
||||||
elif frame.act == 'inform/payment':
|
|
||||||
for slot in frame.slots:
|
|
||||||
self.__memory['payment'][slot.name] = normalize(slot.value)
|
|
||||||
elif frame.act == 'inform/time':
|
|
||||||
for slot in frame.slots:
|
|
||||||
self.__memory['time'][slot.name] = normalize(slot.value)
|
|
||||||
elif frame.act == 'inform/name':
|
|
||||||
for slot in frame.slots:
|
|
||||||
self.__memory['name'][slot.name] = normalize(slot.value)
|
|
||||||
|
|
||||||
def read(self) -> dict:
|
|
||||||
return self.__memory
|
|
||||||
|
|
||||||
def reset(self):
|
|
||||||
self.__memory = copy.deepcopy(self.__initial_state)
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
from src.service.dialog_state_monitor import DialogStateMonitor
|
|
||||||
from src.model.frame import Frame
|
|
||||||
from src.model.slot import Slot
|
|
||||||
|
|
||||||
dst = DialogStateMonitor()
|
|
||||||
|
|
||||||
assert dst.read()['pizza']['capri']['price'] == 25
|
|
||||||
|
|
||||||
dst.update(Frame('user', 'inform/order', [Slot('B-pizza', 'margaritta'), Slot('B-sauce', 'ketchup')]))
|
|
||||||
dst.update(Frame('user', 'inform/order', [Slot('B-pizza', 'carbonara')]))
|
|
||||||
dst.update(Frame('user', 'inform/order-complete', []))
|
|
||||||
|
|
||||||
assert dst.read()['order'][0]['B-pizza'] == 'margaritta'
|
|
||||||
assert dst.read()['order'][0]['B-sauce'] == 'ketchup'
|
|
||||||
assert dst.read()['order-complete'] == True
|
|
||||||
|
|
||||||
dst.reset()
|
|
||||||
|
|
||||||
assert dst.read()['order'] == []
|
|
||||||
assert dst.read()['order-complete'] == False
|
|
Loading…
Reference in New Issue
Block a user