Package games.stendhal.common.parser

Examples of games.stendhal.common.parser.SimilarExprMatcher


  public TriggerExactlyInListCondition(final List<String> triggers) {
    addTriggers(triggers);
  }

  private void addTriggers(Iterable<String> triggers) {
    SimilarExprMatcher matcher = new SimilarExprMatcher();
    for (String trigger : triggers) {
      final Sentence expected = ConversationParser.parse(trigger, matcher);
      this.triggers.add(expected);
    }
  }
View Full Code Here


            public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
              for (int i = 1; i < 9; i++) {
                String joke = jokes.get(i);

                final Sentence answer = sentence.parseAsMatchingSource();
                final Sentence expected = ConversationParser.parse(joke, new SimilarExprMatcher());

                if (answer.matchesFull(expected)) {
                  final String[] questslot = player.getQuest(mithrilcloak.getQuestSlot()).split(";");
                  if (questslot.length > 2) {
                    // if the split worked, we had stored a needle number before and we need to store it again
View Full Code Here

    } else if (sel.equals("exact matching")) {
      selectedMatcher = new ExactExprMatcher();
    } else if (sel.equals("case insensitive")) {
      selectedMatcher = new CaseInsensitiveExprMatcher();
    } else if (sel.equals("similarity matching")) {
      selectedMatcher = new SimilarExprMatcher();
    } else if (sel.equals("controlled matching")) {
      selectedMatcher = null;
    } else if (sel.equals("merged expressions")) {
      selectedMatcher = new ExpressionMatcher();
      mergeExpressions = true;
View Full Code Here

  /**
   * Tests for similarMatching.
   */
  @Test
  public final void testSimilarMatching() {
    final ExpressionMatcher matcher = new SimilarExprMatcher();

    final Expression e1 = new Expression("aBc", "VER");
    final Expression e2 = new Expression("abc", "VER");
    final Expression e3 = new Expression("ab", "VER");
    final Expression e4 = new Expression("abc", "SUB");
    final Expression e5 = new Expression("X", "SUB");
    assertTrue(matcher.match(e1, e2));
    assertFalse(matcher.match(e1, e3));
    assertTrue(matcher.match(e1, e4));
    assertFalse(matcher.match(e1, e5));
    assertFalse(matcher.match(e4, e5));

    final Expression e6 = new Expression("hello", "VER");
    final Expression e7 = new Expression("hallo", "VER");
    final Expression e8 = new Expression("hailo", "VER");
    assertTrue(matcher.match(e6, e7));
    assertFalse(matcher.match(e6, e8));
    assertTrue(matcher.match(e7, e8));
  }
View Full Code Here

* @author madmetzger
*/
public abstract class KnownOffersChatAction implements ChatAction {
  protected Integer getOfferNumberFromSentence(Sentence sentence) {
    final SimilarExprMatcher matcher = new SimilarExprMatcher();
    final int last = sentence.getExpressions().size();
 
    for (Expression expr : sentence.getExpressions().subList(1, last)) {
      if (matcher.match(expr, new Expression("number", "NUM"))) {
        /*
         * The player wrote either "command number", "command number <number>",
         * or something along those lines. Ignore the "number" parts until
         * we get to the actual numeral.
         */
 
View Full Code Here

        public void fire(final Player player, final Sentence sentence, final EventRaiser npc) {
          final String name = player.getQuest(QUEST_SLOT);
          final String quote = quotes.get(name);

          final Sentence answer = sentence.parseAsMatchingSource();
          final Sentence expected = ConversationParser.parse(quote, new SimilarExprMatcher());

          if (answer.matchesFull(expected)) {
            npc.say("Oh right, that's it! How could I forget this? Here, take this handy fishing rod as an acknowledgement of my gratitude!");
            final Item fishingRod = SingletonRepository.getEntityManager().getItem("fishing rod");
            fishingRod.setBoundTo(player.getName());
View Full Code Here

      if (riddleMap.get(riddle) == null) {
        logger.warn("Accepting any answer for unknown riddle: " + riddle);
        return true;
      }
      for (String correct : riddleMap.get(riddle)) {
        final Sentence expected = ConversationParser.parse(correct, new SimilarExprMatcher());
        if (answer.matchesFull(expected)) {
          return true;
        }
      }
View Full Code Here

TOP

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

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.