Class:Parser
Defined in: Adventure/Parser.js, line 5
Description
The Parser class is the core that interprets player input. It takes a string from the player, sanitizes it of undesirable characters, strips away extraneous grammar such as definite/indefinite articles, performs a number of regular expression searches, compares the input against different verb/noun patterns stored in lookup tables, and streamlines the input into a verb, asset IDs, and prepositions. A sentence can be made up of one verb and up to three nouns. Clauses joined by 'and' or 'then' are split into multiple inputs and queued for serial handling. If you would like to see a detailed diagram of the process, see How the Parser Works.
This is an internal class that authors should not need to construct, though there are methods to allow authors to inject their own custom parser code. See Custom Parsers for more info.
Private Constructor:
var foo = new AdventureJS.Parser(game)
Parameters:
-
gameGame
A reference to the game instance.
Engine Classes
- Input Parser class, used as a property of the parser instance, that stores a turn's parsed input.
- ParsedNoun Special class used to store metadata about an asset and lists of all possible matches for that asset.
Asset Classes
- Index
- Methods
- Properties
Index
Methods:
- categorizeAssets
- createParser
- dehydrateStrings
- disableParser
- enableParser
- excludeFromParsedNoun
- findMatchIn
- getInputCount
- getLastInput
- getNewerInput
- getOlderInput
- getRecentPronouns
- handleSentence
- handleWord
- isParsingMultiple
- normalizeInput
- parseInput
- parseNoInput
- parseNoun
- parseNumbers
- parseSentence
- parseVerb
- printNounDisambiguation
- qualifyParsedNoun
- qualifyParsedVerb
- rehydrateStrings
- resetRecentPronouns
- roboticizeInput
- saveVerbPhrase
- selectAll
- selectCarried
- selectCharacter
- selectDOV
- selectEntity
- selectEntityOrSubstance
- selectExtant
- selectGlobalSubstance
- selectHeld
- selectInHands
- selectInHandsUnlessReservoir
- selectInInventory
- selectInInventoryIfTakeable
- selectIntangible
- selectIOV
- selectKnown
- selectNotExit
- selectNotGlobal
- selectNotInHands
- selectNotInInventory
- selectNotNestedIfAll
- selectNotParent
- selectNotParentOrRoom
- selectNotPlayer
- selectNotScenery
- selectNotSelf
- selectNotSubstance
- selectNotWorn
- selectNotWornIfAll
- selectParent
- selectParentOrRoom
- selectPlayer
- selectPresent
- selectPresentIfEntity
- selectReachable
- selectReachableIfEntity
- selectReservoir
- selectReservoirIfSubstance
- selectReservoirOrCarriedIfSubstance
- selectSelf
- selectSingular
- selectSubstance
- selectTakeable
- selectTangible
- selectVisible
- selectVisible
- selectVisibleIfEntity
- set
- setRecentPronouns
- splitSentences
- stripArticles
- tokenizeAnd
- tokenizeBoundaries
- tokenizeBut
- tokenizeCommands
- tokenizeNouns
- tokenizePrepositions
- tokenizeStrings
- tokenizeThen
- tokenizeTryGerunds
- tokenizeTryToVerbs
- tokenizeVerbGerunds
- tokenizeVerbNounPrepNounPrepNouns
- tokenizeVerbNounPrepNouns
- tokenizeVerbNounPrepPrepNouns
- tokenizeVerbNounPreps
- tokenizeVerbPrepNounPrepNounPrepNouns
- tokenizeVerbPrepNounPrepNouns
- tokenizeVerbPrepNouns
- tokenizeVerbPrepPrepNouns
- tokenizeVerbPrepPrepPrepNouns
- tokenizeVerbs
- verifyAdverbs
- verifyCharacterVerb
- verifySentence
- verifySentenceStructure
Properties:
Methods Collapse all |
categorizeAssets
categorizeAssets() → {object}
Defined in: Adventure/Parser/categorizeAssets.js, line 8
Returns:
object
createParser
createParser(parsers)
Defined in: Adventure/Parser/createParser.js, line 7
Parameters:
-
parsersObject
An object containing one or more parser functions.
dehydrateStrings
dehydrateStrings(input) → {String|Boolean}
Defined in: Adventure/Parser/dehydrateStrings.js, line 8
Todos: escape $ in input
Parameters:
-
inputString
Returns:
String
|
Boolean
disableParser
disableParser(parser)
Defined in: Adventure/Parser/disableParser.js, line 7
Parameters:
-
parserString
The name of a previously created parser that has been stored at game.parser.custom_parsers[name].
enableParser
enableParser(parser)
Defined in: Adventure/Parser/enableParser.js, line 7
Parameters:
-
parserString
The name of a previously created parser that has been stored at game.parser.custom_parsers[name].
excludeFromParsedNoun
excludeFromParsedNoun() → {object}
Defined in: Adventure/Parser.js, line 399
Returns:
object
findMatchIn
findMatchIn(newQualified, oldQualified) → {Object}
Defined in: Adventure/Parser/findMatchIn.js, line 8
Parameters:
-
newQualifiedObject -
oldQualifiedObject
Returns:
Object
foundMatch
getInputCount
getInputCount() → {int}
getLastInput
getLastInput() → {String}
getNewerInput
getNewerInput()
Defined in: Adventure/Parser.js, line 325
getOlderInput
getOlderInput()
Defined in: Adventure/Parser.js, line 306
getRecentPronouns
getRecentPronouns()
Defined in: Adventure/Parser.js, line 256
handleSentence
handleSentence()
Defined in: Adventure/Parser/handleSentence.js, line 8
handleWord
handleWord()
Defined in: Adventure/Parser/handleWord.js, line 8
isParsingMultiple
isParsingMultiple()
Defined in: Adventure/Parser.js, line 347
Todos: Is this and is_input_queued duplicative?
normalizeInput
normalizeInput(input) → {String}
Defined in: Adventure/Parser/normalizeInput.js, line 8
Parameters:
-
inputString
- convert tabs to spaces
- trim()
- reduce multiple spaces
- replace " ," with ","
- replace " ." with "."
Returns:
String
parseInput
parseInput(input)
Defined in: Adventure/Parser/parseInput.js, line 8
Parameters:
-
inputString
Player input.
parseNoInput
parseNoInput()
Defined in: Adventure/Parser.js, line 358
parseNoun
parseNoun(word) → {adventurejs.parsedNoun}
Defined in: Adventure/Parser/parseNoun.js, line 8
Parameters:
-
wordString
Returns:
adventurejs.parsedNoun
parseNumbers
parseNumbers(input) → {String}
Defined in: Adventure/Parser/parseNumbers.js, line 8
Parameters:
-
inputString
Player input.
Example:
type 10 on keyboard
Becomes:
type global_number on keyboard
Returns:
String
parseSentence
parseSentence()
Defined in: Adventure/Parser/parseSentence.js, line 8
parseVerb
parseVerb(verb) → {String}
Defined in: Adventure/Parser/parseVerb.js, line 8
Parameters:
-
verbString
One word from input string.
Returns:
String
printNounDisambiguation
printNounDisambiguation(params)
Defined in: Adventure/Parser/printNounDisambiguation.js, line 8
Todos: support for platonics, ie which did you mean, a pistachio from the pouch, or the one | one that you're carrying?
Parameters:
-
paramsObject
qualifyParsedNoun
qualifyParsedNoun(params) → {adventurejs.parsedNoun}
Defined in: Adventure/Parser/qualifyParsedNoun.js, line 8
Parameters:
-
paramsObject
Returns:
adventurejs.parsedNoun
qualifyParsedVerb
qualifyParsedVerb(params)
Defined in: Adventure/Parser/qualifyParsedVerb.js, line 8
Parameters:
-
paramsObject
Returns:
ObjectrehydrateStrings
rehydrateStrings(input) → {String|Boolean}
Defined in: Adventure/Parser/rehydrateStrings.js, line 8
Parameters:
-
inputString
Returns:
String
|
Boolean
resetRecentPronouns
resetRecentPronouns()
Defined in: Adventure/Parser.js, line 265
Todos: how to handle custom pronouns
roboticizeInput
roboticizeInput(input) → {String}
Defined in: Adventure/Parser/roboticizeInput.js, line 8
Parameters:
-
inputString
Returns:
String
saveVerbPhrase
saveVerbPhrase()
Defined in: Adventure/Parser/saveVerbPhrase.js, line 8
selectAll
selectAll(word) → {Array}
Defined in: Adventure/Parser/selectAll.js, line 8
Parameters:
-
wordString
Returns:
Array
selectCarried
selectCarried(list) → {Array}
Defined in: Adventure/Parser/selectCarried.js, line 8
Parameters:
-
listArray
Returns:
Array
selectCharacter
selectCharacter(list) → {Array}
Defined in: Adventure/Parser/selectCharacter.js, line 8
Parameters:
-
listArray
Returns:
Array
selectDOV
selectDOV(list) → {Array}
Defined in: Adventure/Parser/selectDOV.js, line 8
Parameters:
-
listArray
Returns:
Array
selectEntity
selectEntity(list) → {Array}
Defined in: Adventure/Parser/selectEntity.js, line 8
Parameters:
-
listArray
Returns:
Array
selectEntityOrSubstance
selectEntityOrSubstance(list) → {Array}
Defined in: Adventure/Parser/selectEntityOrSubstance.js, line 8
- Yes
Parameters:
-
listArray
Returns:
Array
selectExtant
selectExtant(list) → {Array}
Defined in: Adventure/Parser/selectExtant.js, line 8
Parameters:
-
listArray
Returns:
Array
selectGlobalSubstance
selectGlobalSubstance(list) → {Array}
Defined in: Adventure/Parser/selectGlobalSubstance.js, line 8
Parameters:
-
listArray
Returns:
Array
selectHeld
selectHeld(list) → {Array}
Defined in: Adventure/Parser/selectHeld.js, line 8
Parameters:
-
listArray
Returns:
Array
selectInHands
selectInHands(list) → {Array}
Defined in: Adventure/Parser/selectInHands.js, line 8
Parameters:
-
listArray
Returns:
Array
selectInHandsUnlessReservoir
selectInHandsUnlessReservoir(list) → {Array}
Defined in: Adventure/Parser/selectInHandsUnlessReservoir.js, line 8
Parameters:
-
listArray
Returns:
Array
selectInInventory
selectInInventory(list) → {Array}
Defined in: Adventure/Parser/selectInInventory.js, line 8
Parameters:
-
listArray
Returns:
Array
selectInInventoryIfTakeable
selectInInventoryIfTakeable(list) → {Array}
Defined in: Adventure/Parser/selectInInventoryIfTakeable.js, line 8
Parameters:
-
listArray
Returns:
Array
selectIntangible
selectIntangible(list) → {Array}
Defined in: Adventure/Parser/selectIntangible.js, line 8
Parameters:
-
listArray
Returns:
Array
selectIOV
selectIOV(list) → {Array}
Defined in: Adventure/Parser/selectIOV.js, line 8
Parameters:
-
listArray
Returns:
Array
selectKnown
selectKnown(list) → {Array}
Defined in: Adventure/Parser/selectKnown.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotExit
selectNotExit(list) → {Array}
Defined in: Adventure/Parser/selectNotExit.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotGlobal
selectNotGlobal(list) → {Array}
Defined in: Adventure/Parser/selectNotGlobal.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotInHands
selectNotInHands(list) → {Array}
Defined in: Adventure/Parser/selectNotInHands.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotInInventory
selectNotInInventory(list) → {Array}
Defined in: Adventure/Parser/selectNotInInventory.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotNestedIfAll
selectNotNestedIfAll(list, context) → {Array}
Defined in: Adventure/Parser/selectNotNestedIfAll.js, line 8
Parameters:
-
listArray -
contextObject
An optional context asset, for "take from asset"
Returns:
Array
selectNotParent
selectNotParent(list) → {Array}
Defined in: Adventure/Parser/selectNotParent.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotParentOrRoom
selectNotParentOrRoom(list) → {Array}
Defined in: Adventure/Parser/selectNotParentOrRoom.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotPlayer
selectNotPlayer(list) → {Array}
Defined in: Adventure/Parser/selectNotPlayer.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotScenery
selectNotScenery(list) → {Array}
Defined in: Adventure/Parser/selectNotScenery.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotSelf
selectNotSelf(list) → {Array}
Defined in: Adventure/Parser/selectNotSelf.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotSubstance
selectNotSubstance(list) → {Array}
Defined in: Adventure/Parser/selectNotSubstance.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotWorn
selectNotWorn(list) → {Array}
Defined in: Adventure/Parser/selectNotWorn.js, line 8
Parameters:
-
listArray
Returns:
Array
selectNotWornIfAll
selectNotWornIfAll(list) → {Array}
Defined in: Adventure/Parser/selectNotWornIfAll.js, line 8
Parameters:
-
listArray
Returns:
Array
selectParent
selectParent(list) → {Array}
Defined in: Adventure/Parser/selectParent.js, line 8
Parameters:
-
listArray
Returns:
Array
selectParentOrRoom
selectParentOrRoom(list) → {Array}
Defined in: Adventure/Parser/selectParentOrRoom.js, line 8
Parameters:
-
listArray
Returns:
Array
selectPlayer
selectPlayer(list) → {Array}
Defined in: Adventure/Parser/selectPlayer.js, line 8
Parameters:
-
listArray
Returns:
Array
selectPresent
selectPresent(list) → {Array}
Defined in: Adventure/Parser/selectPresent.js, line 8
Parameters:
-
listArray
Returns:
Array
selectPresentIfEntity
selectPresentIfEntity(list) → {Array}
Defined in: Adventure/Parser/selectPresentIfEntity.js, line 8
Parameters:
-
listArray
Returns:
Array
selectReachable
selectReachable(list) → {Array}
Defined in: Adventure/Parser/selectReachable.js, line 8
Parameters:
-
listArray
Returns:
Array
selectReachableIfEntity
selectReachableIfEntity(list) → {Array}
Defined in: Adventure/Parser/selectReachableIfEntity.js, line 8
Parameters:
-
listArray
Returns:
Array
selectReservoir
selectReservoir(list) → {Array}
Defined in: Adventure/Parser/selectReservoir.js, line 8
Parameters:
-
listArray
Returns:
Array
selectReservoirIfSubstance
selectReservoirIfSubstance(list) → {Array}
Defined in: Adventure/Parser/selectReservoirIfSubstance.js, line 8
Parameters:
-
listArray
Returns:
Array
selectReservoirOrCarriedIfSubstance
selectReservoirOrCarriedIfSubstance(list) → {Array}
Defined in: Adventure/Parser/selectReservoirOrCarriedIfSubstance.js, line 8
Parameters:
-
listArray
Returns:
Array
selectSelf
selectSelf(list) → {Array}
Defined in: Adventure/Parser/selectSelf.js, line 8
Parameters:
-
listArray
Returns:
Array
selectSingular
selectSingular(list) → {Array}
Defined in: Adventure/Parser/selectSingular.js, line 8
Parameters:
-
listArray
Returns:
Array
selectSubstance
selectSubstance(list) → {Array}
Defined in: Adventure/Parser/selectSubstance.js, line 8
Parameters:
-
listArray
Returns:
Array
selectTakeable
selectTakeable(list) → {Array}
Defined in: Adventure/Parser/selectTakeable.js, line 8
Parameters:
-
listArray
Returns:
Array
selectTangible
selectTangible(list) → {Array}
Defined in: Adventure/Parser/selectTangible.js, line 8
Parameters:
-
listArray
Returns:
Array
selectVisible
selectVisible(list) → {Array}
Defined in: Adventure/Parser/selectVisible.js, line 8
Todos: consider global darkness
Parameters:
-
listArray
Returns:
Array
selectVisible
selectVisible(list) → {Array}
Defined in: Adventure/Parser/selectWorn.js, line 8
Parameters:
-
listArray
Returns:
Array
selectVisibleIfEntity
selectVisibleIfEntity(list) → {Array}
Defined in: Adventure/Parser/selectVisibleIfEntity.js, line 8
Todos: consider global darkness
Parameters:
-
listArray
Returns:
Array
set
set(props) → {AdventureJS.Parser}
Defined in: Adventure/Parser.js, line 416
Parameters:
-
propsObject
A generic object containing properties to copy to the Object instance.
Returns:
AdventureJS.Parser
Returns the instance the method is called on (useful for chaining calls.)
setRecentPronouns
setRecentPronouns()
Defined in: Adventure/Parser.js, line 169
Todos: this needs additional logic to handle custom pronouns
splitSentences
splitSentences(input) → {String}
Defined in: Adventure/Parser/splitSentences.js, line 8
Todos: multi-turn handling for instructions given to NPCs ex: Roger, go east then drop lamp
Parameters:
-
inputString
Returns:
String
stripArticles
stripArticles(input) → {String}
Defined in: Adventure/Parser/stripArticles.js, line 8
Parameters:
-
inputString
Player input.
Convert some common compound prepositions into single words to streamline preposition handling.
Returns:
String
tokenizeAnd
tokenizeAnd(input) → {String}
Defined in: Adventure/Parser/tokenizeAnd.js, line 8
Parameters:
-
inputString
- as a conjunction
- "take glass key and silver key"
- "take all but glass key and silver key"
- "take glass key, silver key"
- "take all but glass key, silver key"
- as a sentence boundary (like "then")
- "take glass key and go north"
- "jump and go north"
- "jump up and go north"
- "go east and go north"
- STRETCH: "put a in b and c in d"
When used as a sentence boundary, we convert "and" to " | ", which will be used to split sentences in a later step.
We also look for chained prepositional phrases:
"put a in b and c in d (ad infinitum)"
Returns:
String
tokenizeBoundaries
tokenizeBoundaries(input) → {String}
Defined in: Adventure/Parser/tokenizeBoundaries.js, line 8
Parameters:
-
inputString
Returns:
String
tokenizeBut
tokenizeBut(input_string) → {String}
Defined in: Adventure/Parser/tokenizeBut.js, line 8
Parameters:
-
input_stringString
Player input string.
In order to handle sentences with multiple nouns connected by 'but', we convert 'but' to a symbol we can use down the line.
Returns:
String
tokenizeCommands
tokenizeCommands(input) → {String|Boolean}
Defined in: Adventure/Parser/tokenizeCommands.js, line 8
Parameters:
-
inputString
Player input.
Returns:
String
|
Boolean
tokenizeNouns
tokenizeNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeNouns.js, line 8
Todos: This might be too greedy, or perhaps need to exclude first word of input. I had a room called "Put Plug In This" and this method parsed "put plug in sink" to "put_plug_in_this in sink" Alternately, revise the method that populates world_lookup for instance world_lookup has keys for "Plug Something With Something" and "sink with"
Parameters:
-
inputString
Player input.
Search input for multi-word phrases that are not names, such as "north door" to describe an aperture related to a north exit, by comparing the input string against entries in game.world_lookup, which contains space delimited phrases as well as single words which make up those phrases.
For example if we had an object named: "Maxwell's silver hammer"
User might ask for "hammer" or "silver hammer" or "maxwell's silver hammer" In order to maximize chances of understanding partial user input, each word of the phrase becomes a separate entry in world_lookup.
When performing search/replace we don't want to accidentally replace substrings of larger phrases, which means we need to search for longer phrases first and work our way down. We also need to ensure we don't substitute words in phrases we've already serialized.
Unfortunately we can't just sort world_lookup by word count because JS object properties aren't indexed, by definition. Instead we figure out the longest word count property and do a loop for each word count from the longest down to two words. (No substitution is needed for single words.)
Returns:
String
tokenizePrepositions
tokenizePrepositions(input) → {String}
Defined in: Adventure/Parser/tokenizePrepositions.js, line 8
Parameters:
-
inputString
Player input.
Returns:
String
tokenizeStrings
tokenizeStrings(input) → {String}
Defined in: Adventure/Parser/tokenizeStrings.js, line 8
Parameters:
-
inputString
Player input.
Example:
type "foo" on keyboard
Became:
type $0 on keyboard
And now becomes:
type global_string on keyboard
Returns:
String
tokenizeThen
tokenizeThen(input) → {String}
Defined in: Adventure/Parser/tokenizeThen.js, line 8
Todos: what about "take sword then shield" ?
Parameters:
-
inputString
Each clause separated by 'then' is a distinct input. We treat clauses as unrelated without dependencies and stack each into a queue.
Example: "take sword then go north"
Returns:
String
tokenizeTryGerunds
tokenizeTryGerunds(input) → {String}
Defined in: Adventure/Parser/tokenizeTryGerunds.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "try verbing". We compare the input string against entries in dictionary.try_gerunds, which was populated automatically at initialization. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"try swimming"
is identified as
"swim"
Returns:
String
tokenizeTryToVerbs
tokenizeTryToVerbs(input) → {String}
Defined in: Adventure/Parser/tokenizeTryToVerbs.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "try to verb". We compare the input string against entries in dictionary.try_to_verbs, which was populated automatically at initialization. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"try to swim"
is identified as
"swim"
Returns:
String
tokenizeVerbGerunds
tokenizeVerbGerunds(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbGerunds.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb gerund" such as "go swimming". We compare the input string against entries in dictionary.verb_gerunds, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"go swimming"
is identified as
"swim"
Returns:
String
tokenizeVerbNounPrepNounPrepNouns
tokenizeVerbNounPrepNounPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbNounPrepNounPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb noun prep noun prep noun". We compare the input string against entries in dictionary.verb_noun_prep_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that matches an entry, we save a record for use with future verb logic.
For example:
"tie dog to tree with rope"
is identified as
"tie_to_with dog tree rope"
Returns:
String
tokenizeVerbNounPrepNouns
tokenizeVerbNounPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbNounPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb noun preposition noun". We compare the input string against entries in dictionary.verb_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"ask grocer about eggplant"
is identified as
"ask_about grocer eggplant"
Returns:
String
tokenizeVerbNounPrepPrepNouns
tokenizeVerbNounPrepPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbNounPrepPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb noun preposition preposition noun". We compare the input string against entries in dictionary.verb_noun_prep_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"take skateboard from under bed"
is identified as
"take_from skateboard bed"
Returns:
String
tokenizeVerbNounPreps
tokenizeVerbNounPreps(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbNounPreps.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb noun preposition". We compare the input string against entries in dictionary.verb_noun_preps, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"lock chest up"
is identified as
"lockUp chest"
Returns:
String
tokenizeVerbPrepNounPrepNounPrepNouns
tokenizeVerbPrepNounPrepNounPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbPrepNounPrepNounPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb preposition noun preposition noun preposition noun". We compare the input string against entries in dictionary.verb_prep_noun_prep_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"swing from tree to stalactite on vine"
is identified as
"swing_from_to_on tree stalactite vine".
Returns:
String
tokenizeVerbPrepNounPrepNouns
tokenizeVerbPrepNounPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbPrepNounPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb prep noun prep noun". We compare the input string against entries in dictionary.verb_prep_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"jump from branch to vine"
is identified as
"jumpFrom_to branch vine"
Returns:
String
tokenizeVerbPrepNouns
tokenizeVerbPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb prep noun". We compare the input string against entries in dictionary.verb_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"look in desk"
is identified as
"lookIn desk"
Returns:
String
tokenizeVerbPrepPrepNouns
tokenizeVerbPrepPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbPrepPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb prep prep noun". We compare the input string against entries in dictionary.verb_prep_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"get out of boat"
is identified as
"go_out boat"
Returns:
String
tokenizeVerbPrepPrepPrepNouns
tokenizeVerbPrepPrepPrepNouns(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbPrepPrepPrepNouns.js, line 8
Parameters:
-
inputString
Player input.
Search input for verb phrases in the format of "verb prep prep prep noun". We compare the input string against entries in dictionary.verb_prep_prep_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"get out from behind boulder"
is identified as
"go_out_from_behind boulder"
Returns:
String
tokenizeVerbs
tokenizeVerbs(input) → {String}
Defined in: Adventure/Parser/tokenizeVerbs.js, line 29
Parameters:
-
inputString
Player input.
tokenizeVerbs identifies phrasal or compound verb
patterns such as "swing from tree to cliff on vine". This feature
is mostly retired but for use in a small few instances such as
aiding in identifying "plug in computer" vs "plug drain". An earlier
version of the parser used this extensively to join phrasal verbs
into distinct verbs such as "swing_from_to_on tree cliff vine",
which worked well but ultimately proved to be inflexible.
The listed order of regex operations is important. We're calling them in order of longest to shortest, to ensure we don't accidentally catch partial phrases, like only finding "swing_from" out of "swing from tree to cliff on vine", and then not finding "swing_from_to_on", which is a distinct pattern.
Returns:
String
verifyAdverbs
verifyAdverbs()
Defined in: Adventure/Parser/verifyAdverb.js, line 8
verifyCharacterVerb
verifyCharacterVerb(optional_verb)
Defined in: Adventure/Parser/verifyCharacterVerb.js, line 8
Parameters:
-
optional_verbstring
An optional verb. If not provided, method uses this_turn.input_verb.
Returns:
booleanverifySentence
verifySentence()
Defined in: Adventure/Parser/verifySentence.js, line 8
verifySentenceStructure
verifySentenceStructure()
Defined in: Adventure/Parser/verifySentenceStructure.js, line 8
Properties |
custom_parsers
custom_parsers :Object
Defined in: Adventure/Parser.js, line 58
Default value: {}
custom_parsers_enabled
custom_parsers_enabled :Object
Defined in: Adventure/Parser.js, line 65
Default value: {}
dictionary
dictionary :Object
Defined in: Adventure/Parser.js, line 44
Default value: {}
display
display :Object
Defined in: Adventure/Parser.js, line 51
Default value: {}
game
game :Object
Defined in: Adventure/Parser.js, line 37
Default value: {}
input_history
input_history :Array
Defined in: Adventure/Parser.js, line 88
Default value: []
input_history_index
input_history_index :int
Defined in: Adventure/Parser.js, line 105
input_object
input_object :Object
input_queue
input_queue :Array
Defined in: Adventure/Parser.js, line 112
Default value: []
input_string
input_string :String
Defined in: Adventure/Parser.js, line 74
Default value: ""
is_input_queued
is_input_queued :Boolean
Defined in: Adventure/Parser.js, line 129
Default value: false
phrasal_patterns
phrasal_patterns :Array
Defined in: Adventure/Parser/tokenizeVerbs.js, line 8
recent_pronouns
recent_pronouns :Object
Defined in: Adventure/Parser.js, line 138
Default value: {}
Todos: how to handle custom pronouns