/**
   * public void testTemplateOr() { Template t1 = new Template("var({X})"); Template t2 = new
   * Template("var3"); Template t3 = new Template("bli"); Template or = new
   * Template(Arrays.asList(t1, t2, t3)); assertTrue(or.match("var3").isMatching());
   * assertTrue(or.match("var(blo)").isMatching()); assertTrue(or.match("bli").isMatching());
   * assertFalse(or.match("var3bli").isMatching()); assertFalse(or.match("var").isMatching()); }
   */
  @Test
  public void testTemplateQuick() {
    Domain domain = XMLDomainReader.extractDomain("test/domains/quicktest.xml");
    DialogueSystem system = new DialogueSystem(domain);
    system.getSettings().showGUI = false;

    system.startSystem();
    assertEquals(system.getContent("caught").getProb(false), 1.0, 0.01);
    assertEquals(system.getContent("caught2").getProb(true), 1.0, 0.01);
  }
Exemple #2
0
 private static Domain extractDomain(String simulatorDomain) {
   if (simulatorDomain == null) {
     throw new RuntimeException("Required parameter: simulatorDomain");
   }
   return XMLDomainReader.extractDomain(simulatorDomain);
 }
Exemple #3
0
  // @Test
  public void parsingTest() throws InterruptedException {
    DialogueSystem system = new DialogueSystem(XMLDomainReader.extractDomain(DOMAIN_FILE));
    system.getSettings().showGUI = false;
    system.getSettings().params.setProperty("taggingmodel", TAGGING_MODEL);
    system.getSettings().params.setProperty("parsingmodel", PARSING_MODEL);
    system.attachModule(MaltParser.class);
    system.startSystem();
    system.addUserInput("move to the left");
    assertTrue(system.getState().hasChanceNode("parse(u_u)"));
    assertTrue(system.getState().hasChanceNode("a_u"));
    assertEquals(system.getContent("a_u").toDiscrete().getBest().toString(), "Move(left)");
    system.addUserInput("what do you see now?");
    assertTrue(system.getState().hasChanceNode("parse(u_u)"));
    assertEquals(system.getContent("a_u").toDiscrete().getBest().toString(), "Move(left)");
    Map<String, Double> table = new HashMap<String, Double>();
    table.put("move a little bit to the left", 0.7);
    table.put("move a bit to the left", 0.1);
    system.addUserInput(table);
    assertTrue(system.getState().hasChanceNode("parse(u_u)"));
    assertTrue(system.getState().hasChanceNode("a_u"));
    assertEquals(system.getContent("a_u").toDiscrete().getProb("Move(left)"), 0.8, 0.01);

    table = new HashMap<String, Double>();
    table.put("now move a bit to the right please", 0.6);
    system.addUserInput(table);
    assertTrue(system.getState().hasChanceNode("parse(u_u)"));
    assertTrue(system.getState().hasChanceNode("a_u"));
    assertEquals(system.getContent("a_u").toDiscrete().getProb("Move(right)"), 0.6, 0.01);
    ParseValue pv =
        (ParseValue)
            system
                .getContent("parse(u_u)")
                .getValues()
                .stream()
                .filter(v -> v instanceof ParseValue)
                .findFirst()
                .get();
    assertTrue(pv.contains(ValueFactory.create("TO DT JJ")));
    assertFalse(pv.contains(ValueFactory.create("DT TT JJ")));
    assertTrue(pv.contains(ValueFactory.create("(*,the,*,det,7)")));
    assertTrue(pv.contains(ValueFactory.create("(7,*,JJ,*,*)")));
    assertTrue(pv.contains(ValueFactory.create("(*,*,DT,det,7)")));
    assertTrue(pv.contains(ValueFactory.create("(7,right,*,*,*)")));
    assertFalse(pv.contains(ValueFactory.create("(7,left,*,*,*)")));
    assertTrue(pv.contains(ValueFactory.create("TO the JJ")));
    assertTrue(pv.contains(ValueFactory.create("to the JJ")));
    assertTrue(pv.contains(ValueFactory.create("TO DT right")));
    assertFalse(pv.contains(ValueFactory.create("TO DT left")));
    assertTrue(pv.contains(ValueFactory.create("to/TO the/DT right/JJ")));
    assertFalse(pv.contains(ValueFactory.create("to/JJ the/DT right/JJ")));
    assertTrue(pv.contains(ValueFactory.create("(*,the,DT,det,7)")));
    assertTrue(pv.contains(ValueFactory.create("(7,right,JJ,*,*)")));
    assertTrue(pv.contains(ValueFactory.create("JJ")));
    assertFalse(pv.contains(ValueFactory.create("RBR")));
    table = new HashMap<String, Double>();
    table.put("this is a gnome", 0.6);
    system.addUserInput(table);
    pv =
        (ParseValue)
            system
                .getContent("parse(u_u)")
                .getValues()
                .stream()
                .filter(v -> v instanceof ParseValue)
                .findFirst()
                .get();
    assertTrue(pv.contains(ValueFactory.create("DT VBZ DT NN")));
    assertEquals("Test successful", system.getContent("i_u").getBest().toString());
  }