add reference number generator
This commit is contained in:
parent
29700baaf9
commit
1dcb6c7343
@ -1,11 +1,18 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import json
|
import json
|
||||||
|
import random
|
||||||
|
import string
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from convlab.policy.policy import Policy
|
from convlab.policy.policy import Policy
|
||||||
|
|
||||||
db_path = './hotels_data.json'
|
db_path = './hotels_data.json'
|
||||||
|
|
||||||
|
|
||||||
|
def generate_reference_number(length=8):
|
||||||
|
letters_and_digits = string.ascii_uppercase + string.digits
|
||||||
|
reference_number = ''.join(random.choice(letters_and_digits) for _ in range(length))
|
||||||
|
return reference_number
|
||||||
|
|
||||||
class DialoguePolicy(Policy):
|
class DialoguePolicy(Policy):
|
||||||
info_dict = None
|
info_dict = None
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -41,7 +48,8 @@ class DialoguePolicy(Policy):
|
|||||||
if any(True for slots in user_action.values() for (slot, _) in slots if
|
if any(True for slots in user_action.values() for (slot, _) in slots if
|
||||||
slot in ['book stay', 'book day', 'book people']):
|
slot in ['book stay', 'book day', 'book people']):
|
||||||
if self.results:
|
if self.results:
|
||||||
system_action = {('Booking', 'Book'): [["Ref", self.results[0].get('Ref', 'N/A')]]}
|
reference_number = generate_reference_number()
|
||||||
|
system_action = {('Booking', 'Book'): [["Ref", reference_number]]}
|
||||||
|
|
||||||
system_acts = [[intent, domain, slot, value] for (domain, intent), slots in system_action.items() for
|
system_acts = [[intent, domain, slot, value] for (domain, intent), slots in system_action.items() for
|
||||||
slot, value in slots]
|
slot, value in slots]
|
||||||
|
Loading…
Reference in New Issue
Block a user