Package games.stendhal.common.parser
Class ConversationParser
java.lang.Object
games.stendhal.common.ErrorBuffer
games.stendhal.common.parser.ConversationParser
- All Implemented Interfaces:
ErrorDrain
Parser for conversations with a SpeakerNPC This class parses strings in English language and returns them as Sentence
objects. All sentence constituents are in lower case.
- Author:
- Martin Fuchs
-
Field Summary
Fields inherited from class games.stendhal.common.ErrorBuffer
errorBuffer
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConversationParser(SentenceImplementation sentence)
Create a new conversation parser and initialise with the given sentence. -
Method Summary
Modifier and TypeMethodDescriptionstatic Expression
createTriggerExpression(String text)
Create trigger expression to match the parsed user input in the FSM engine.static Expression
createTriggerExpression(String text, ExpressionMatcher matcher)
Create trigger expression to match the parsed user input in the FSM engine.static String
detectSentenceType(String text, Sentence sentence)
Evaluates and sets sentence type by looking at the trailing punctuation characters.static String
static Sentence
Parse function without conversation context.static Sentence
parse(String text, ConversationContext ctx)
Parse the given text sentence.static Sentence
parse(String text, ConversationContext ctx, ExpressionMatcher matcher)
Parse the given text sentence using an ConversationContext and an explicit Expression matcher.static Sentence
parse(String text, ExpressionMatcher matcher)
Parse the given text sentence using an explicit Expression matcher.static Sentence
parseAsMatcher(String text)
Parse the given text sentence to be used for sentence matching.static Sentence
parseAsMatchingSource(String text)
Parse the given text sentence to be used as matching source.Read the next word from the parsed sentence.Methods inherited from class games.stendhal.common.ErrorBuffer
getErrorString, hasError, setError
-
Constructor Details
-
ConversationParser
Create a new conversation parser and initialise with the given sentence.- Parameters:
sentence
-
-
-
Method Details
-
normalize
- Parameters:
text
-- Returns:
- the sentence in normalized form.
-
createTriggerExpression
Create trigger expression to match the parsed user input in the FSM engine.- Parameters:
text
-- Returns:
- Expression
-
createTriggerExpression
Create trigger expression to match the parsed user input in the FSM engine.- Parameters:
text
-matcher
-- Returns:
- Expression
-
parse
Parse function without conversation context.- Parameters:
text
-- Returns:
- the parsed text
-
parseAsMatchingSource
Parse the given text sentence to be used as matching source.- Parameters:
text
-- Returns:
- the parsed text
-
parseAsMatcher
Parse the given text sentence to be used for sentence matching.- Parameters:
text
-- Returns:
- the parsed text
-
parse
Parse the given text sentence using an explicit Expression matcher.- Parameters:
text
-matcher
-- Returns:
- the parsed text
-
parse
Parse the given text sentence using an ConversationContext and an explicit Expression matcher.- Parameters:
text
-ctx
-matcher
-- Returns:
- the parsed text
-
parse
Parse the given text sentence.- Parameters:
text
-ctx
-- Returns:
- the parsed text
-
readNextWord
Read the next word from the parsed sentence.- Returns:
- word string
-
detectSentenceType
Evaluates and sets sentence type by looking at the trailing punctuation characters.- Parameters:
text
- the text to evaluatesentence
- where the type is to be set- Returns:
- text without trailing or leading punctuation
-