Examples of Sentence


Examples of games.stendhal.common.parser.Sentence

  public boolean fire(final Player player, final Sentence sentence, final Entity entity) {

    // TODO: lowercase "and" at the beginning of a sentence is ignored, even in full match mode: "and the other gold"

    final Sentence answer = ConversationParser.parse(sentence.getOriginalText(), CONVERSION_CONTEXT);
    for (Sentence trigger : triggers) {
      if (answer.matchesFull(trigger)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

          new ChatAction() {
            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

Examples of games.stendhal.common.parser.Sentence

    return type.toString();
  }

  private void processSentence(String text) {
    Sentence sentence = ConversationParser.parse(text);

    tfTrimmed.setText(sentence.getTrimmedText());

    tfNormalized.setText(sentence.getNormalized());

    tfToString.setText(sentence.toString());

    tfTrigger.setText(sentence.getTriggerExpression().toString());

    String subj = sentence.getSubjectName();
    tfSubject.setText(subj != null ? subj :
      "[" + sentence.getSubjectCount() + " subjects]");

    String verb = sentence.getVerbString();
    tfVerb.setText(verb != null ? verb :
      "[" + sentence.getVerbCount() + " verbs]");

    Expression num = sentence.getNumeral();
    tfNumeral.setText(num != null ? num.getNormalized() :
      "[" + sentence.getNumeralCount() + " numerals]");

    String obj = sentence.getObjectName();
    tfObject.setText(obj != null ? obj :
      "[" + sentence.getObjectCount() + " objects]");

    HTMLDocument d = initHtml(tpExpressions);

    int unknown = 0;
    for (Expression e : sentence) {
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

    lbUnknownWarning.setVisible(unknown > 0);
  }

  private void processMatching(String text, String matchText, ExpressionMatcher matcher, boolean mergeExpressions) {
    Sentence matchSentence, sentence;

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    if (mergeExpressions) {
      // standard parsing including expression merging
      matchSentence = ConversationParser.parse(matchText);
    } else if (matcher == null) {
      // simple parsing for matching
      matchSentence = ConversationParser.parseAsMatcher(matchText);
      // detect matching mode in "controlled matching" mode from the given matching text
      matcher = matchSentence.getMatcher();
    } else {
      // parse with the given matcher object
      matchSentence = ConversationParser.parse(matchText, matcher);
    }

    tfParsedMatchString.setText(matchSentence.toString());

    if (mergeExpressions) {
      // standard parsing including expression merging
      sentence = ConversationParser.parse(text);
    } else if (matcher == null) {
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

        if (waitMessage != null) {
          say(waitMessage);
        }

        if (waitAction != null) {
          final Sentence sentence = ConversationParser.parse(text);
          // Note: sentence is currently not yet used in
          // the called handler functions.
          waitAction.fire(player, sentence, new EventRaiser(this));
        }
      }
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

  /**
   * Tests for sentenceMatching.
   */
  @Test
  public final void testSentenceMatching() {
    final Sentence m1 = ConversationParser.parseAsMatcher("|SIMILAR|hello");
    assertFalse(m1.hasError());
    assertEquals("|SIMILAR|hello", m1.toString());

    assertEquals(true, ConversationParser.parse("hello").matchesFull(m1));
    assertEquals(true, ConversationParser.parse("hallo").matchesFull(m1));
    assertEquals(false, ConversationParser.parse("hailo").matchesFull(m1));
  }
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

   *
   * @return <code>true</code> if the user can use the portal.
   */
  @Override
  protected boolean isAllowed(final RPEntity user) {
    Sentence sentence = ConversationParser.parse(user.get("text"));
    if (condition != null) {
      return condition.fire((Player) user, sentence, this);
    }
    return true;
  }
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

  /**
   * Tests for sentenceMatching.
   */
  @Test
  public final void testSentenceMatching() {
    Sentence m1 = ConversationParser.parseAsMatcher("|ICASE|hello");
    assertFalse(m1.hasError());
    assertEquals("|ICASE|hello", m1.toString());

    assertEquals(true, ConversationParser.parse("hello").matchesFull(m1));
    assertEquals(true, ConversationParser.parse("hallo").matchesFull(m1));
    assertEquals(false, ConversationParser.parse("hailo").matchesFull(m1));

    m1 = ConversationParser.parseAsMatcher("|EXACT|ICASE|hello");
    assertFalse(m1.hasError());
    assertEquals("|EXACT|ICASE|hello", m1.toString());

    assertEquals(true, ConversationParser.parse("hello").matchesFull(m1));
    assertEquals(false, ConversationParser.parse("hallo").matchesFull(m1));
    assertEquals(false, ConversationParser.parse("hailo").matchesFull(m1));
  }
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

   * @param text
   *            input
   * @return true if a transition was made, false otherwise
   */
  public boolean step(final Player player, final String text) {
    final Sentence sentence = ConversationParser.parse(text);

    if (sentence.hasError()) {
      logger.warn("problem parsing the sentence '" + text + "': "
          + sentence.getErrorString());
    }

    return step(player, sentence);
  }
View Full Code Here

Examples of games.stendhal.common.parser.Sentence

   */
  public boolean stepTest(final Player player, final String text) {
    logger.debug(">>> " + text);
    speakerNPC.remove("text");

    final Sentence sentence = ConversationParser.parse(text);

    if (sentence.hasError()) {
      logger.warn("problem parsing the sentence '" + text + "': "
          + sentence.getErrorString());
    }

    final boolean res = step(player, sentence);

    logger.debug("<<< " + speakerNPC.get("text"));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.