diff --git a/modelscope/models/__init__.py b/modelscope/models/__init__.py index 4720af9d..678d0b38 100644 --- a/modelscope/models/__init__.py +++ b/modelscope/models/__init__.py @@ -10,6 +10,5 @@ from .multi_modal import OfaForImageCaptioning from .nlp import (BertForMaskedLM, BertForSequenceClassification, SbertForNLI, SbertForSentenceSimilarity, SbertForSentimentClassification, SbertForTokenClassification, SpaceForDialogIntentModel, - SpaceForDialogModelingModel, - SpaceForDialogStateTrackingModel, StructBertForMaskedLM, - VecoForMaskedLM) + SpaceForDialogModelingModel, SpaceForDialogStateTracking, + StructBertForMaskedLM, VecoForMaskedLM) diff --git a/modelscope/models/nlp/space/dialog_state_tracking_model.py b/modelscope/models/nlp/space/dialog_state_tracking_model.py index 00fc968a..256d4fa9 100644 --- a/modelscope/models/nlp/space/dialog_state_tracking_model.py +++ b/modelscope/models/nlp/space/dialog_state_tracking_model.py @@ -6,11 +6,11 @@ from ....utils.nlp.space.utils_dst import batch_to_device from ...base import Model, Tensor from ...builder import MODELS -__all__ = ['SpaceForDialogStateTrackingModel'] +__all__ = ['SpaceForDialogStateTracking'] @MODELS.register_module(Tasks.dialog_state_tracking, module_name=r'space') -class SpaceForDialogStateTrackingModel(Model): +class SpaceForDialogStateTracking(Model): def __init__(self, model_dir: str, *args, **kwargs): """initialize the test generation model from the `model_dir` path. diff --git a/modelscope/pipelines/nlp/dialog_state_tracking_pipeline.py b/modelscope/pipelines/nlp/dialog_state_tracking_pipeline.py index 1a1d542a..fc257e09 100644 --- a/modelscope/pipelines/nlp/dialog_state_tracking_pipeline.py +++ b/modelscope/pipelines/nlp/dialog_state_tracking_pipeline.py @@ -1,7 +1,7 @@ from typing import Any, Dict from ...metainfo import Pipelines -from ...models import SpaceForDialogStateTrackingModel +from ...models import SpaceForDialogStateTracking from ...preprocessors import DialogStateTrackingPreprocessor from ...utils.constant import Tasks from ..base import Pipeline @@ -14,7 +14,7 @@ __all__ = ['DialogStateTrackingPipeline'] Tasks.dialog_state_tracking, module_name=Pipelines.dialog_state_tracking) class DialogStateTrackingPipeline(Pipeline): - def __init__(self, model: SpaceForDialogStateTrackingModel, + def __init__(self, model: SpaceForDialogStateTracking, preprocessor: DialogStateTrackingPreprocessor, **kwargs): """use `model` and `preprocessor` to create a nlp text classification pipeline for prediction diff --git a/modelscope/preprocessors/space/examples b/modelscope/preprocessors/space/examples deleted file mode 100644 index bfaafccf..00000000 --- a/modelscope/preprocessors/space/examples +++ /dev/null @@ -1,3776 +0,0 @@ -########### 第一个例子 ############ -# 之前的例子变成完整的对话,是个单领域的简单例子 - -utter1 = { - 'User-1': - 'am looking for a place to to stay that has cheap price range it should be in a type of hotel' - } -history_states1 = [ - {}, - ] -utter2 = { - 'User-1': - 'am looking for a place to to stay that has cheap price range it should be in a type of hotel', - 'System-1': - 'Okay, do you have a specific area you want to stay in?', - 'Dialog_Act-1': { - 'Hotel-Request': [['Area', '?']] - }, - 'User-2': - 'no, i just need to make sure it\'s cheap. oh, and i need parking', - } -history_states2 = [{}, { - 'taxi': { - 'book': { - 'booked': [] - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'departure': '', - 'arriveBy': '' - } - }, - 'police': { - 'book': { - 'booked': [] - }, - 'semi': {} - }, - 'restaurant': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'time': '' - }, - 'semi': { - 'food': '', - 'pricerange': '', - 'name': '', - 'area': '' - } - }, - 'hospital': { - 'book': { - 'booked': [] - }, - 'semi': { - 'department': '' - } - }, - 'hotel': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'stay': '' - }, - 'semi': { - 'name': 'not mentioned', - 'area': 'not mentioned', - 'parking': 'not mentioned', - 'pricerange': 'cheap', - 'stars': 'not mentioned', - 'internet': 'not mentioned', - 'type': 'hotel' - } - }, - 'attraction': { - 'book': { - 'booked': [] - }, - 'semi': { - 'type': '', - 'name': '', - 'area': '' - } - }, - 'train': { - 'book': { - 'booked': [], - 'people': '' - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': '' - } - } - }, {}] -utter3 = { - 'User-1': - 'am looking for a place to to stay that has cheap price range it should be in a type of hotel', - 'System-1': 'Okay, do you have a specific area you want to stay in?', - 'Dialog_Act-1': { - 'Hotel-Request': [['Area', '?']] - }, - 'User-2': - 'no, i just need to make sure it\'s cheap. oh, and i need parking', - 'System-2': - 'I found 1 cheap hotel for you that includes parking. Do you like me to book it?', - 'Dialog_Act-2': { - 'Booking-Inform': [['none', 'none']], - 'Hotel-Inform': [['Price', 'cheap'], ['Choice', '1'], - ['Parking', 'none']] - }, - 'User-3': 'Yes, please. 6 people 3 nights starting on tuesday.' - } - -history_states3 = [{}, - { - 'taxi': { - 'book': { - 'booked': [] - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'departure': '', - 'arriveBy': '' - } - }, - 'police': { - 'book': { - 'booked': [] - }, - 'semi': {} - }, - 'restaurant': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'time': '' - }, - 'semi': { - 'food': '', - 'pricerange': '', - 'name': '', - 'area': '' - } - }, - 'hospital': { - 'book': { - 'booked': [] - }, - 'semi': { - 'department': '' - } - }, - 'hotel': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'stay': '' - }, - 'semi': { - 'name': 'not mentioned', - 'area': 'not mentioned', - 'parking': 'not mentioned', - 'pricerange': 'cheap', - 'stars': 'not mentioned', - 'internet': 'not mentioned', - 'type': 'hotel' - } - }, - 'attraction': { - 'book': { - 'booked': [] - }, - 'semi': { - 'type': '', - 'name': '', - 'area': '' - } - }, - 'train': { - 'book': { - 'booked': [], - 'people': '' - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': '' - } - } - }, {}, - { - 'taxi': { - 'book': { - 'booked': [] - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'departure': '', - 'arriveBy': '' - } - }, - 'police': { - 'book': { - 'booked': [] - }, - 'semi': {} - }, - 'restaurant': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'time': '' - }, - 'semi': { - 'food': '', - 'pricerange': '', - 'name': '', - 'area': '' - } - }, - 'hospital': { - 'book': { - 'booked': [] - }, - 'semi': { - 'department': '' - } - }, - 'hotel': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'stay': '' - }, - 'semi': { - 'name': 'not mentioned', - 'area': 'not mentioned', - 'parking': 'yes', - 'pricerange': 'cheap', - 'stars': 'not mentioned', - 'internet': 'not mentioned', - 'type': 'hotel' - } - }, - 'attraction': { - 'book': { - 'booked': [] - }, - 'semi': { - 'type': '', - 'name': '', - 'area': '' - } - }, - 'train': { - 'book': { - 'booked': [], - 'people': '' - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': '' - } - } - }, {}] -utter4 = { - 'User-1': - 'am looking for a place to to stay that has cheap price range it should be in a type of hotel', - 'System-1': 'Okay, do you have a specific area you want to stay in?', - 'Dialog_Act-1': { - 'Hotel-Request': [['Area', '?']] - }, - 'User-2': - 'no, i just need to make sure it\'s cheap. oh, and i need parking', - 'System-2': - 'I found 1 cheap hotel for you that includes parking. Do you like me to book it?', - 'Dialog_Act-2': { - 'Booking-Inform': [['none', 'none']], - 'Hotel-Inform': [['Price', 'cheap'], ['Choice', '1'], - ['Parking', 'none']] - }, - 'User-3': 'Yes, please. 6 people 3 nights starting on tuesday.', - 'System-3': - 'I am sorry but I wasn\'t able to book that for you for Tuesday. Is there another day you would like to stay or perhaps a shorter stay?', - 'Dialog_Act-3': { - "Booking-NoBook": [ - [ - "Day", - "Tuesday" - ] - ], - "Booking-Request": [ - [ - "Stay", - "?" - ], - [ - "Day", - "?" - ] - ] - }, - 'User-4': 'how about only 2 nights.', - } -history_states4 = [{}, - { - 'taxi': { - 'book': { - 'booked': [] - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'departure': '', - 'arriveBy': '' - } - }, - 'police': { - 'book': { - 'booked': [] - }, - 'semi': {} - }, - 'restaurant': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'time': '' - }, - 'semi': { - 'food': '', - 'pricerange': '', - 'name': '', - 'area': '' - } - }, - 'hospital': { - 'book': { - 'booked': [] - }, - 'semi': { - 'department': '' - } - }, - 'hotel': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'stay': '' - }, - 'semi': { - 'name': 'not mentioned', - 'area': 'not mentioned', - 'parking': 'not mentioned', - 'pricerange': 'cheap', - 'stars': 'not mentioned', - 'internet': 'not mentioned', - 'type': 'hotel' - } - }, - 'attraction': { - 'book': { - 'booked': [] - }, - 'semi': { - 'type': '', - 'name': '', - 'area': '' - } - }, - 'train': { - 'book': { - 'booked': [], - 'people': '' - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': '' - } - } - }, {}, - { - 'taxi': { - 'book': { - 'booked': [] - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'departure': '', - 'arriveBy': '' - } - }, - 'police': { - 'book': { - 'booked': [] - }, - 'semi': {} - }, - 'restaurant': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'time': '' - }, - 'semi': { - 'food': '', - 'pricerange': '', - 'name': '', - 'area': '' - } - }, - 'hospital': { - 'book': { - 'booked': [] - }, - 'semi': { - 'department': '' - } - }, - 'hotel': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'stay': '' - }, - 'semi': { - 'name': 'not mentioned', - 'area': 'not mentioned', - 'parking': 'yes', - 'pricerange': 'cheap', - 'stars': 'not mentioned', - 'internet': 'not mentioned', - 'type': 'hotel' - } - }, - 'attraction': { - 'book': { - 'booked': [] - }, - 'semi': { - 'type': '', - 'name': '', - 'area': '' - } - }, - 'train': { - 'book': { - 'booked': [], - 'people': '' - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': '' - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "6", - "day": "tuesday", - "stay": "3" - }, - "semi": { - "name": "not mentioned", - "area": "not mentioned", - "parking": "yes", - "pricerange": "cheap", - "stars": "not mentioned", - "internet": "not mentioned", - "type": "hotel" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "", - "destination": "", - "day": "", - "arriveBy": "", - "departure": "" - } - } - }, {}] -utter5 = { - 'User-1': - 'am looking for a place to to stay that has cheap price range it should be in a type of hotel', - 'System-1': 'Okay, do you have a specific area you want to stay in?', - 'Dialog_Act-1': { - 'Hotel-Request': [['Area', '?']] - }, - 'User-2': - 'no, i just need to make sure it\'s cheap. oh, and i need parking', - 'System-2': - 'I found 1 cheap hotel for you that includes parking. Do you like me to book it?', - 'Dialog_Act-2': { - 'Booking-Inform': [['none', 'none']], - 'Hotel-Inform': [['Price', 'cheap'], ['Choice', '1'], - ['Parking', 'none']] - }, - 'User-3': 'Yes, please. 6 people 3 nights starting on tuesday.', - 'System-3': - 'I am sorry but I wasn\'t able to book that for you for Tuesday. Is there another day you would like to stay or perhaps a shorter stay?', - 'Dialog_Act-3': { - "Booking-NoBook": [ - [ - "Day", - "Tuesday" - ] - ], - "Booking-Request": [ - [ - "Stay", - "?" - ], - [ - "Day", - "?" - ] - ] - }, - 'User-4': 'how about only 2 nights.', - 'System-4': - 'Booking was successful.\nReference number is : 7GAWK763. Anything else I can do for you?', - 'Dialog_Act-4': { - "general-reqmore": [ - [ - "none", - "none" - ] - ], - "Booking-Book": [ - [ - "Ref", - "7GAWK763" - ] - ] - }, - 'User-5': 'No, that will be all. Good bye.', - } -history_states5 = [{}, - { - 'taxi': { - 'book': { - 'booked': [] - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'departure': '', - 'arriveBy': '' - } - }, - 'police': { - 'book': { - 'booked': [] - }, - 'semi': {} - }, - 'restaurant': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'time': '' - }, - 'semi': { - 'food': '', - 'pricerange': '', - 'name': '', - 'area': '' - } - }, - 'hospital': { - 'book': { - 'booked': [] - }, - 'semi': { - 'department': '' - } - }, - 'hotel': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'stay': '' - }, - 'semi': { - 'name': 'not mentioned', - 'area': 'not mentioned', - 'parking': 'not mentioned', - 'pricerange': 'cheap', - 'stars': 'not mentioned', - 'internet': 'not mentioned', - 'type': 'hotel' - } - }, - 'attraction': { - 'book': { - 'booked': [] - }, - 'semi': { - 'type': '', - 'name': '', - 'area': '' - } - }, - 'train': { - 'book': { - 'booked': [], - 'people': '' - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': '' - } - } - }, {}, - { - 'taxi': { - 'book': { - 'booked': [] - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'departure': '', - 'arriveBy': '' - } - }, - 'police': { - 'book': { - 'booked': [] - }, - 'semi': {} - }, - 'restaurant': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'time': '' - }, - 'semi': { - 'food': '', - 'pricerange': '', - 'name': '', - 'area': '' - } - }, - 'hospital': { - 'book': { - 'booked': [] - }, - 'semi': { - 'department': '' - } - }, - 'hotel': { - 'book': { - 'booked': [], - 'people': '', - 'day': '', - 'stay': '' - }, - 'semi': { - 'name': 'not mentioned', - 'area': 'not mentioned', - 'parking': 'yes', - 'pricerange': 'cheap', - 'stars': 'not mentioned', - 'internet': 'not mentioned', - 'type': 'hotel' - } - }, - 'attraction': { - 'book': { - 'booked': [] - }, - 'semi': { - 'type': '', - 'name': '', - 'area': '' - } - }, - 'train': { - 'book': { - 'booked': [], - 'people': '' - }, - 'semi': { - 'leaveAt': '', - 'destination': '', - 'day': '', - 'arriveBy': '', - 'departure': '' - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "6", - "day": "tuesday", - "stay": "3" - }, - "semi": { - "name": "not mentioned", - "area": "not mentioned", - "parking": "yes", - "pricerange": "cheap", - "stars": "not mentioned", - "internet": "not mentioned", - "type": "hotel" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "", - "destination": "", - "day": "", - "arriveBy": "", - "departure": "" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [ - { - "name": "the cambridge belfry", - "reference": "7GAWK763" - } - ], - "people": "6", - "day": "tuesday", - "stay": "2" - }, - "semi": { - "name": "not mentioned", - "area": "not mentioned", - "parking": "yes", - "pricerange": "cheap", - "stars": "not mentioned", - "internet": "not mentioned", - "type": "hotel" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "", - "destination": "", - "day": "", - "arriveBy": "", - "departure": "" - } - } - }, {}] - - -############## 第二个例子 ########## -# 选出一个复杂的对话,涉及到多领域 -utter1 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?' - } -history_states1 = [ - {}, - ] -utter2 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?', - 'System-1': - 'There are over 1,000 trains like that. Where will you be departing from?', - 'Dialog_Act-1': { - "Train-Inform": [ - [ - "Choice", - "over 1" - ], - [ - "Choice", - "000" - ] - ], - "Train-Request": [ - [ - "Depart", - "?" - ] - ] - }, - 'User-2': - 'I am departing from birmingham new street.', - } -history_states2 = [{}, { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "not mentioned" - } - } - }, {}] - -utter3 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?', - 'System-1': - 'There are over 1,000 trains like that. Where will you be departing from?', - 'Dialog_Act-1': { - "Train-Inform": [ - [ - "Choice", - "over 1" - ], - [ - "Choice", - "000" - ] - ], - "Train-Request": [ - [ - "Depart", - "?" - ] - ] - }, - 'User-2': - 'I am departing from birmingham new street.', - 'System-2': - 'Can you confirm your desired travel day?', - 'Dialog_Act-2': { - "Train-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-3': 'I would like to leave on wednesday' - } -history_states3 = [{}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "not mentioned" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}] -utter4 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?', - 'System-1': - 'There are over 1,000 trains like that. Where will you be departing from?', - 'Dialog_Act-1': { - "Train-Inform": [ - [ - "Choice", - "over 1" - ], - [ - "Choice", - "000" - ] - ], - "Train-Request": [ - [ - "Depart", - "?" - ] - ] - }, - 'User-2': - 'I am departing from birmingham new street.', - 'System-2': - 'Can you confirm your desired travel day?', - 'Dialog_Act-2': { - "Train-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-3': 'I would like to leave on wednesday', - 'System-3': - 'I show a train leaving birmingham new street at 17:40 and arriving at 20:23 on Wednesday. Will this work for you?', - 'Dialog_Act-3': { - "Train-Inform": [ - [ - "Arrive", - "20:23" - ], - [ - "Leave", - "17:40" - ], - [ - "Day", - "Wednesday" - ], - [ - "Depart", - "birmingham new street" - ] - ] - }, - 'User-4': 'That will, yes. Please make a booking for 5 people please.', - } -history_states4 = [{}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "not mentioned" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}] -utter5 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?', - 'System-1': - 'There are over 1,000 trains like that. Where will you be departing from?', - 'Dialog_Act-1': { - "Train-Inform": [ - [ - "Choice", - "over 1" - ], - [ - "Choice", - "000" - ] - ], - "Train-Request": [ - [ - "Depart", - "?" - ] - ] - }, - 'User-2': - 'I am departing from birmingham new street.', - 'System-2': - 'Can you confirm your desired travel day?', - 'Dialog_Act-2': { - "Train-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-3': 'I would like to leave on wednesday', - 'System-3': - 'I show a train leaving birmingham new street at 17:40 and arriving at 20:23 on Wednesday. Will this work for you?', - 'Dialog_Act-3': { - "Train-Inform": [ - [ - "Arrive", - "20:23" - ], - [ - "Leave", - "17:40" - ], - [ - "Day", - "Wednesday" - ], - [ - "Depart", - "birmingham new street" - ] - ] - }, - 'User-4': 'That will, yes. Please make a booking for 5 people please.', - 'System-4': - 'I\'ve booked your train tickets, and your reference number is A9NHSO9Y.', - 'Dialog_Act-4': { - "Train-OfferBooked": [ - [ - "Ref", - "A9NHSO9Y" - ] - ] - }, - 'User-5': 'Thanks so much. I would also need a place to say. I am looking for something with 4 stars and has free wifi.' - } -history_states5 = [{}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "not mentioned" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - ] - -utter6 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?', - 'System-1': - 'There are over 1,000 trains like that. Where will you be departing from?', - 'Dialog_Act-1': { - "Train-Inform": [ - [ - "Choice", - "over 1" - ], - [ - "Choice", - "000" - ] - ], - "Train-Request": [ - [ - "Depart", - "?" - ] - ] - }, - 'User-2': - 'I am departing from birmingham new street.', - 'System-2': - 'Can you confirm your desired travel day?', - 'Dialog_Act-2': { - "Train-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-3': 'I would like to leave on wednesday', - 'System-3': - 'I show a train leaving birmingham new street at 17:40 and arriving at 20:23 on Wednesday. Will this work for you?', - 'Dialog_Act-3': { - "Train-Inform": [ - [ - "Arrive", - "20:23" - ], - [ - "Leave", - "17:40" - ], - [ - "Day", - "Wednesday" - ], - [ - "Depart", - "birmingham new street" - ] - ] - }, - 'User-4': 'That will, yes. Please make a booking for 5 people please.', - 'System-4': - 'I\'ve booked your train tickets, and your reference number is A9NHSO9Y.', - 'Dialog_Act-4': { - "Train-OfferBooked": [ - [ - "Ref", - "A9NHSO9Y" - ] - ] - }, - 'User-5': 'Thanks so much. I would also need a place to say. I am looking for something with 4 stars and has free wifi.', - 'System-5': - 'How about the cambridge belfry? It has all the attributes you requested and a great name! Maybe even a real belfry?', - 'Dialog_Act-5': { - "Hotel-Recommend": [ - [ - "Name", - "the cambridge belfry" - ] - ] - }, - 'User-6': 'That sounds great, could you make a booking for me please?', - } -history_states6 = [{}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "not mentioned" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "not mentioned", - "area": "not mentioned", - "parking": "not mentioned", - "pricerange": "not mentioned", - "stars": "4", - "internet": "yes", - "type": "none" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {} - ] - -utter7 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?', - 'System-1': - 'There are over 1,000 trains like that. Where will you be departing from?', - 'Dialog_Act-1': { - "Train-Inform": [ - [ - "Choice", - "over 1" - ], - [ - "Choice", - "000" - ] - ], - "Train-Request": [ - [ - "Depart", - "?" - ] - ] - }, - 'User-2': - 'I am departing from birmingham new street.', - 'System-2': - 'Can you confirm your desired travel day?', - 'Dialog_Act-2': { - "Train-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-3': 'I would like to leave on wednesday', - 'System-3': - 'I show a train leaving birmingham new street at 17:40 and arriving at 20:23 on Wednesday. Will this work for you?', - 'Dialog_Act-3': { - "Train-Inform": [ - [ - "Arrive", - "20:23" - ], - [ - "Leave", - "17:40" - ], - [ - "Day", - "Wednesday" - ], - [ - "Depart", - "birmingham new street" - ] - ] - }, - 'User-4': 'That will, yes. Please make a booking for 5 people please.', - 'System-4': - 'I\'ve booked your train tickets, and your reference number is A9NHSO9Y.', - 'Dialog_Act-4': { - "Train-OfferBooked": [ - [ - "Ref", - "A9NHSO9Y" - ] - ] - }, - 'User-5': 'Thanks so much. I would also need a place to say. I am looking for something with 4 stars and has free wifi.', - 'System-5': - 'How about the cambridge belfry? It has all the attributes you requested and a great name! Maybe even a real belfry?', - 'Dialog_Act-5': { - "Hotel-Recommend": [ - [ - "Name", - "the cambridge belfry" - ] - ] - }, - 'User-6': 'That sounds great, could you make a booking for me please?', - 'System-6': - 'What day would you like your booking for?', - 'Dialog_Act-6': { - "Booking-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-7': 'Please book it for Wednesday for 5 people and 5 nights, please.', - } -history_states7 = [{}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "not mentioned" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "not mentioned", - "area": "not mentioned", - "parking": "not mentioned", - "pricerange": "not mentioned", - "stars": "4", - "internet": "yes", - "type": "none" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "cambridge belfry", - "area": "not mentioned", - "parking": "not mentioned", - "pricerange": "not mentioned", - "stars": "4", - "internet": "yes", - "type": "none" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {} - ] - - -utter8 = { - 'User-1': - 'Hi, I\'m looking for a train that is going to cambridge and arriving there by 20:45, is there anything like that?', - 'System-1': - 'There are over 1,000 trains like that. Where will you be departing from?', - 'Dialog_Act-1': { - "Train-Inform": [ - [ - "Choice", - "over 1" - ], - [ - "Choice", - "000" - ] - ], - "Train-Request": [ - [ - "Depart", - "?" - ] - ] - }, - 'User-2': - 'I am departing from birmingham new street.', - 'System-2': - 'Can you confirm your desired travel day?', - 'Dialog_Act-2': { - "Train-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-3': 'I would like to leave on wednesday', - 'System-3': - 'I show a train leaving birmingham new street at 17:40 and arriving at 20:23 on Wednesday. Will this work for you?', - 'Dialog_Act-3': { - "Train-Inform": [ - [ - "Arrive", - "20:23" - ], - [ - "Leave", - "17:40" - ], - [ - "Day", - "Wednesday" - ], - [ - "Depart", - "birmingham new street" - ] - ] - }, - 'User-4': 'That will, yes. Please make a booking for 5 people please.', - 'System-4': - 'I\'ve booked your train tickets, and your reference number is A9NHSO9Y.', - 'Dialog_Act-4': { - "Train-OfferBooked": [ - [ - "Ref", - "A9NHSO9Y" - ] - ] - }, - 'User-5': 'Thanks so much. I would also need a place to say. I am looking for something with 4 stars and has free wifi.', - 'System-5': - 'How about the cambridge belfry? It has all the attributes you requested and a great name! Maybe even a real belfry?', - 'Dialog_Act-5': { - "Hotel-Recommend": [ - [ - "Name", - "the cambridge belfry" - ] - ] - }, - 'User-6': 'That sounds great, could you make a booking for me please?', - 'System-6': - 'What day would you like your booking for?', - 'Dialog_Act-6': { - "Booking-Request": [ - [ - "Day", - "?" - ] - ] - }, - 'User-7': 'Please book it for Wednesday for 5 people and 5 nights, please.', - 'System-7': - 'Booking was successful. Reference number is : 5NAWGJDC.', - 'Dialog_Act-7': { - "Booking-Book": [ - [ - "Ref", - "5NAWGJDC" - ] - ] - }, - 'User-8': 'Thank you, goodbye', - } -history_states8 = [{}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "not mentioned" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "not mentioned", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [], - "people": "" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "", - "area": "", - "parking": "", - "pricerange": "", - "stars": "", - "internet": "", - "type": "" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "not mentioned", - "area": "not mentioned", - "parking": "not mentioned", - "pricerange": "not mentioned", - "stars": "4", - "internet": "yes", - "type": "none" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [], - "people": "", - "day": "", - "stay": "" - }, - "semi": { - "name": "cambridge belfry", - "area": "not mentioned", - "parking": "not mentioned", - "pricerange": "not mentioned", - "stars": "4", - "internet": "yes", - "type": "none" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - { - "taxi": { - "book": { - "booked": [] - }, - "semi": { - "leaveAt": "", - "destination": "", - "departure": "", - "arriveBy": "" - } - }, - "police": { - "book": { - "booked": [] - }, - "semi": {} - }, - "restaurant": { - "book": { - "booked": [], - "people": "", - "day": "", - "time": "" - }, - "semi": { - "food": "", - "pricerange": "", - "name": "", - "area": "" - } - }, - "hospital": { - "book": { - "booked": [] - }, - "semi": { - "department": "" - } - }, - "hotel": { - "book": { - "booked": [ - { - "name": "the cambridge belfry", - "reference": "5NAWGJDC" - } - ], - "people": "5", - "day": "wednesday", - "stay": "5" - }, - "semi": { - "name": "cambridge belfry", - "area": "not mentioned", - "parking": "not mentioned", - "pricerange": "not mentioned", - "stars": "4", - "internet": "yes", - "type": "none" - } - }, - "attraction": { - "book": { - "booked": [] - }, - "semi": { - "type": "", - "name": "", - "area": "" - } - }, - "train": { - "book": { - "booked": [ - { - "trainID": "TR4977", - "reference": "A9NHSO9Y" - } - ], - "people": "5" - }, - "semi": { - "leaveAt": "not mentioned", - "destination": "cambridge", - "day": "wednesday", - "arriveBy": "20:45", - "departure": "birmingham new street" - } - } - }, {}, - ] - diff --git a/tests/pipelines/nlp/test_dialog_state_tracking.py b/tests/pipelines/nlp/test_dialog_state_tracking.py index fbb87b42..f3cda06b 100644 --- a/tests/pipelines/nlp/test_dialog_state_tracking.py +++ b/tests/pipelines/nlp/test_dialog_state_tracking.py @@ -5,7 +5,7 @@ import tempfile import unittest from modelscope.hub.snapshot_download import snapshot_download -from modelscope.models import Model, SpaceForDialogStateTrackingModel +from modelscope.models import Model, SpaceForDialogStateTracking from modelscope.pipelines import DialogStateTrackingPipeline, pipeline from modelscope.preprocessors import DialogStateTrackingPreprocessor from modelscope.utils.constant import Tasks @@ -81,7 +81,7 @@ class DialogStateTrackingTest(unittest.TestCase): cache_path = '/Users/yangliu/Space/maas_model/nlp_space_dialog-state-tracking' # cache_path = snapshot_download(self.model_id) - model = SpaceForDialogStateTrackingModel(cache_path) + model = SpaceForDialogStateTracking(cache_path) preprocessor = DialogStateTrackingPreprocessor(model_dir=cache_path) pipelines = [ DialogStateTrackingPipeline( @@ -94,20 +94,19 @@ class DialogStateTrackingTest(unittest.TestCase): pipelines_len = len(pipelines) import json - for _test_case in self.test_case: - history_states = [{}] - utter = {} - for step, item in enumerate(_test_case): - utter.update(item) - result = pipelines[step % pipelines_len]({ - 'utter': - utter, - 'history_states': - history_states - }) - print(json.dumps(result)) + history_states = [{}] + utter = {} + for step, item in enumerate(self.test_case): + utter.update(item) + result = pipelines[step % pipelines_len]({ + 'utter': + utter, + 'history_states': + history_states + }) + print(json.dumps(result)) - history_states.extend([result['dialog_states'], {}]) + history_states.extend([result['dialog_states'], {}]) @unittest.skip('test with snapshot_download') def test_run_with_model_from_modelhub(self):