Exemple #1
0
    def test_reward_learner(self):
        system = DialogueSystem()
        Settings.nr_samples = Settings.nr_samples * 2

        out_break = False
        for k in range(3):
            if out_break is True:
                break

            if k > 0:
                # log message
                pass

            system = DialogueSystem(
                XMLDomainReader.extract_domain(TestSimulator.main_domain2))
            sim_domain3 = XMLDomainReader.extract_domain(
                TestSimulator.sim_domain2)
            sim = Simulator(system, sim_domain3)
            system.attach_module(sim)

            # NEED GUI
            system.get_settings().show_gui = False

            system.start_system()

            for i in range(20):
                if system.get_module(Simulator) is None:
                    break

                sleep(0.1)

                try:
                    self.check_condition2(system)
                    system.detach_module(Simulator)
                    out_break = True
                    break
                except:
                    assert False

            system.detach_module(Simulator)

        self.check_condition2(system)
        system.detach_module(Simulator)
        system.pause(True)
        theta_correct = system.get_content(
            "theta_correct").to_continuous().get_function()
        theta_incorrect = system.get_content(
            "theta_incorrect").to_continuous().get_function()
        theta_repeat = system.get_content(
            "theta_repeat").to_continuous().get_function()
        self.log.debug("theta_correct %s" % theta_correct)
        self.log.debug("theta_incorrect %s" % theta_incorrect)
        self.log.debug("theta_repeat %s" % theta_repeat)

        Settings.nr_samples = Settings.nr_samples / 2.0
Exemple #2
0
    def test_simulator(self):
        system = DialogueSystem()
        nr_samples = Settings.nr_samples
        Settings.nr_samples = nr_samples / 5.0

        out_break = False
        for k in range(3):
            if out_break:
                break

            system = DialogueSystem(
                XMLDomainReader.extract_domain(TestSimulator.main_domain))
            if k > 0:
                self.log.warning("restarting the simulator...")
                pass

            system.get_domain().get_models().pop(0)
            system.get_domain().get_models().pop(0)
            system.get_domain().get_models().pop(0)

            sim_domain2 = XMLDomainReader.extract_domain(
                TestSimulator.sim_domain)
            sim = Simulator(system, sim_domain2)

            system.attach_module(sim)

            # NEED GUI
            system.get_settings().show_gui = False

            system.start_system()

            for i in range(40):
                if system.get_module(Simulator) is None:
                    break
                sleep(0.2)

                # NEED DialogueRecorder
                str = system.get_module(DialogueRecorder).get_record()
                try:
                    self.check_condition(str)
                    system.detach_module(Simulator)
                    out_break = True
                    break
                except:
                    pass

            if not out_break:
                system.detach_module(Simulator)

        # NEED DialogueRecorder
        self.check_condition(system.get_module(DialogueRecorder).get_record())

        system.detach_module(Simulator)
        system.pause(True)
        Settings.nr_samples = nr_samples * 5
Exemple #3
0
if args.domain:
    try:
        domain = XMLDomainReader.extract_domain(args.domain)
        system.log.info("Domain from %s successfully extracted" % args.domain)
    except Exception as e:
        system.display_comment("Cannot load domain: %s" % e)
        domain = XMLDomainReader.extract_empty_domain(args.domain)
    system.change_domain(domain)

if args.simulator:
    simulator = Simulator(system,
                          XMLDomainReader.extract_domain(args.simulator))
    system.log.info("Simulator with domain %s successfully extracted" %
                    args.simulator)
    system.attach_module(simulator)

settings = system.get_settings()
system.change_settings(settings)

if os.path.exists(settings.GOOGLE_APPLICATION_CREDENTIALS):
    os.environ[
        "GOOGLE_APPLICATION_CREDENTIALS"] = settings.GOOGLE_APPLICATION_CREDENTIALS
    system.attach_module(GoogleSTT(system))
    system.attach_module(GoogleTTS(system))
    print('Google SST/TTS modules are attached.')
else:
    print(
        "In order to use Google SST/TTS modules, please specify your 'GOOGLE_APPLICATION_CREDENTIALS' in settings.yml"
    )