# Path: airdialogue/context_generator/context_generator_lib.py
# class ContextGenerator(object):
#   def __init__(self, num_candidate_airports, book_window, num_db_record,
#                firstname_file, lastname_file, airportcode_file):
#   def _generate_user_action(self, expected_action):
#   def generate_context(self,
#                        num_context,
#                        output_data=None,
#                        output_kb=None,
#                        display_freq=None,
#                        output_object=False,
#                        verbose=False):
# 
# Path: airdialogue/context_generator/src/utils.py
# def continue_booking(facts, ag_cond, kb, goal_str):
# def airflight_selector(facts, condition, airfare_database):
# def generate_expected_action(facts, agent_condition, airfare_database,
#                              reservation):
# def check_states(user_action, expected_action):
# def get_day_segment_by_hour(hour):
# def check_condition(facts, flight, condition, get_full_diff=False):
# def generate_action(flights, name, status):
# def standardize_intent(org_intent):
# def standardize_action(org_action):
# def get_unix_epoch(dt):
# def get_datetime(unix_epoch):
# def get_month_and_day(fact_obj, unix_epoch):
# def get_hour(unix_epoch):
# def discrete_price(original_price):
# def format_time(hour):
# def get_connection(con):
# def discrete_sample_(probabilities):
# def choice(values, cnt=-1, p=None):
# 
# Path: airdialogue/simulator/interaction.py
# class Interaction(object):
#   def __init__(self,
#                fact_obj,
#                skip_greeting=0,
#                fix_response_candidate=True,
#                first_ask_prob=0,
#                regret_prob=0,
#                random_respond_error=False):
#   def get_template(self, list_of_templates):
#   def customer_turn(self, utterance):
#   def agent_turn(self, utterance):
#   def generate_confirmation(self, flight, full=True):
#   def airflight_selector(self, condition, airfare_database):
#   def get_flight_from_flight_number(self, flight_number, airfare_database):
#   def get_message(self, ag_condition, cus_condition, erro_state):
#   def generate_greetings(self, utterance, speaker):
#   def generate_agent_ask(self, utterance):
#   def generate_customer_request(self, customer_condition, agent_condition,
#                                 utterance):
#   def no_reservation(self, utterance):
#   def cancel_reservation(self, utterance):
#   def fulfill_basic_requirement(self, goal, cus_cond, ag_cond, utterance):
#   def continue_booking(self, cus_cond, ag_cond, kb, utterance):
#   def generate_dialogue(self, customer, knowledge_base):


import argparse
import json
import tensorflow.compat.v1 as tf
import sys
from tensorflow.compat.v1 import gfile as gfile
from airdialogue.context_generator import context_generator_lib
from airdialogue.context_generator.src import utils
from airdialogue.simulator import interaction
    print("Output_kb: ", FLAGS.output_kb)
    print("Output_data: ", FLAGS.output_data)

  num_samples = FLAGS.num_samples
  cg = context_generator_lib.ContextGenerator(
      num_candidate_airports=FLAGS.num_candidate_airports,
      book_window=FLAGS.book_window,
      num_db_record=FLAGS.num_db_record,
      firstname_file=FLAGS.firstname_file,
      lastname_file=FLAGS.lastname_file,
      airportcode_file=FLAGS.airportcode_file)
  inter = interaction.Interaction(
      cg.fact_obj,
      skip_greeting=0,
      fix_response_candidate=True,
      first_ask_prob=0,
      random_respond_error=True)
  ct, stats = cg.generate_context(num_samples, output_object=True)
  if FLAGS.verbose:
    print(stats)
  with gfile.Open(FLAGS.output_data,
                  "w") as f_data, gfile.Open(FLAGS.output_kb, "w") as f_kb:
    for i in range(len(ct)):
      if FLAGS.verbose and i % 5000 == 0:
        print((i, "/", len(ct)))
      cus, kb, expected_action = ct[i]
      # action has been standarlized in inter
      utterance, action, _ = inter.generate_dialogue(cus, kb)
      standarlized_intent = utils.standardize_intent(cus.get_json())
      standarlized_action = utils.standardize_action(action)

# Path: airdialogue/context_generator/context_generator_lib.py
# class ContextGenerator(object):
#   def __init__(self, num_candidate_airports, book_window, num_db_record,
#                firstname_file, lastname_file, airportcode_file):
#   def _generate_user_action(self, expected_action):
#   def generate_context(self,
#                        num_context,
#                        output_data=None,
#                        output_kb=None,
#                        display_freq=None,
#                        output_object=False,
#                        verbose=False):
# 
# Path: airdialogue/context_generator/src/utils.py
# def continue_booking(facts, ag_cond, kb, goal_str):
# def airflight_selector(facts, condition, airfare_database):
# def generate_expected_action(facts, agent_condition, airfare_database,
#                              reservation):
# def check_states(user_action, expected_action):
# def get_day_segment_by_hour(hour):
# def check_condition(facts, flight, condition, get_full_diff=False):
# def generate_action(flights, name, status):
# def standardize_intent(org_intent):
# def standardize_action(org_action):
# def get_unix_epoch(dt):
# def get_datetime(unix_epoch):
# def get_month_and_day(fact_obj, unix_epoch):
# def get_hour(unix_epoch):
# def discrete_price(original_price):
# def format_time(hour):
# def get_connection(con):
# def discrete_sample_(probabilities):
# def choice(values, cnt=-1, p=None):
# 
# Path: airdialogue/simulator/interaction.py
# class Interaction(object):
#   def __init__(self,
#                fact_obj,
#                skip_greeting=0,
#                fix_response_candidate=True,
#                first_ask_prob=0,
#                regret_prob=0,
#                random_respond_error=False):
#   def get_template(self, list_of_templates):
#   def customer_turn(self, utterance):
#   def agent_turn(self, utterance):
#   def generate_confirmation(self, flight, full=True):
#   def airflight_selector(self, condition, airfare_database):
#   def get_flight_from_flight_number(self, flight_number, airfare_database):
#   def get_message(self, ag_condition, cus_condition, erro_state):
#   def generate_greetings(self, utterance, speaker):
#   def generate_agent_ask(self, utterance):
#   def generate_customer_request(self, customer_condition, agent_condition,
#                                 utterance):
#   def no_reservation(self, utterance):
#   def cancel_reservation(self, utterance):
#   def fulfill_basic_requirement(self, goal, cus_cond, ag_cond, utterance):
#   def continue_booking(self, cus_cond, ag_cond, kb, utterance):
#   def generate_dialogue(self, customer, knowledge_base):


# Path: airdialogue/simulator/simulator_main.py
import argparse
import json
import tensorflow.compat.v1 as tf
import sys
from tensorflow.compat.v1 import gfile as gfile
from airdialogue.context_generator import context_generator_lib
from airdialogue.context_generator.src import utils
from airdialogue.simulator import interaction

    print("Output_kb: ", FLAGS.output_kb)
    print("Output_data: ", FLAGS.output_data)

  num_samples = FLAGS.num_samples
  cg = context_generator_lib.ContextGenerator(
      num_candidate_airports=FLAGS.num_candidate_airports,
      book_window=FLAGS.book_window,
      num_db_record=FLAGS.num_db_record,
      firstname_file=FLAGS.firstname_file,
      lastname_file=FLAGS.lastname_file,
      airportcode_file=FLAGS.airportcode_file)
  inter = interaction.Interaction(
      cg.fact_obj,
      skip_greeting=0,
      fix_response_candidate=True,
      first_ask_prob=0,
      random_respond_error=True)
  ct, stats = cg.generate_context(num_samples, output_object=True)
  if FLAGS.verbose:
    print(stats)
  with gfile.Open(FLAGS.output_data,
                  "w") as f_data, gfile.Open(FLAGS.output_kb, "w") as f_kb:
    for i in range(len(ct)):
      if FLAGS.verbose and i % 5000 == 0:
        print((i, "/", len(ct)))
      cus, kb, expected_action = ct[i]
      # action has been standarlized in inter
      utterance, action, _ = inter.generate_dialogue(cus, kb)
      standarlized_intent = utils.standardize_intent(cus.get_json())
      standarlized_action = utils.standardize_action(action)

      standarlized_expected_action = utils.standardize_action(expected_action)