Package games.stendhal.common.parser

Examples of games.stendhal.common.parser.ConversationContext


   */
  @Test
  public final void testParsing() {
    final ExpressionMatcher matcher = new ExpressionMatcher();

    Sentence sentence = matcher.parseSentence("", new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("", sentence.toString());

    String str = matcher.readMatchingFlags("Lazy dog");
    assertEquals("Lazy dog", str);
    assertTrue(matcher.isEmpty());
    assertEquals("", matcher.toString());

    sentence = matcher.parseSentence(str, new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("lazy dog/SUB-ANI", sentence.toString());

    str = matcher.readMatchingFlags("|TYPE|abcdef/OBJ");
    assertEquals("abcdef/OBJ", str);
    assertTrue(matcher.isAnyFlagSet());
    assertFalse(matcher.getExactMatching());
    assertTrue(matcher.getTypeMatching());
    assertEquals("|TYPE", matcher.toString());

    sentence = matcher.parseSentence(str, new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("|TYPE|abcdef/OBJ", sentence.toString());

    str = matcher.readMatchingFlags("|EXACT|Hello world!");
    assertEquals("Hello world!", str);
    assertTrue(matcher.isAnyFlagSet());
    assertTrue(matcher.getExactMatching());
    assertFalse(matcher.getTypeMatching());
    assertEquals("|EXACT", matcher.toString());

    sentence = matcher.parseSentence(str, new ConversationContext());
    assertFalse(sentence.hasError());
    assertEquals("|EXACT|Hello world!", sentence.toString());
  }
View Full Code Here


  /**
   * Tests for sentenceMatching.
   */
  @Test
  public final void testEquality() {
    final ConversationContext ctx1 = new ConversationContext();
    final ConversationContext ctx2 = new ConversationContext();
   
    assertEquals(ctx1, ctx2);
    assertTrue(ctx1.equals(ctx2));

    ctx1.forMatching = true;
View Full Code Here

  /**
   * Grammar tests.
   */
  @Test
  public final void testGrammar() {
    final ConversationContext ctx = new ConversationContext();

    SentenceImplementation sentence = new SentenceImplementation(ctx, "The quick brown fox jumps over the lazy dog.");
    ConversationParser parser = new ConversationParser(sentence);
    sentence.parse(parser);
    sentence.classifyWords(parser);
View Full Code Here

   * Tests for Sentence.parse().
   */
  @Test
  public final void testParse() {
    Sentence s1 = ConversationParser.parse("Give me a red ball please.");
    Sentence m1 = s1.parse(new ConversationContext());
    assertFalse(s1.hasError());
    assertFalse(m1.hasError());
    assertEquals("buy/VER red ball/OBJ-COL!", s1.toString());
    assertEquals("buy/VER red ball/OBJ-COL!", m1.toString());
    assertTrue(s1.matchesFull(m1));
View Full Code Here

TOP

Related Classes of games.stendhal.common.parser.ConversationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.