Advanced Verb Use:Phrasal Verbs
In addition to the verb properties covered in the previous doc, there is also
a lesser used set of properties that can be used to define phrasal verb
patterns, which get converted into
regular expressions
that can be used to find verb phrases consisting of a verb and one or more
prepositions separated by nouns. For example, you might define verb
tie_to_with to handle input such as
"tie dog to tree with rope", with the pattern
verb_noun_prep_noun_prep_noun: ["tie to with"]. It's also
possible to define multiple patterns for a single noun. Here's an example of
how to define a verb with phrasal patterns.
MyGame.createVerb({
name: "tie_to_with",
prettyname: "tie to",
verb_noun_prep_noun_prep_noun: ["tie to with"],
doTry: function (input) {
// custom logic here
return true;
},
doSuccess: function (input) {
// custom logic here
return true;
},
});
Earlier in its development, AdventureJS relied exclusively on finding verb
phrases. For example, instead of one swing verb, it had separate
verbs for swing_to, swing_to_on,
swing_on_to, swing_from_to, and
swing_from_to_on. Eventually, it moved toward more robust (and
complex) natural language processing and concomitant logic. But, the earlier
system remains in place and is used for a few verbs like go to.
Authors wishing to write custom verbs may find this system easier than writing
logic to handle all prepositions. The function that joins phrasal verbs is
called early in the input parsing cycle, meaning that custom verbs defined
this way will take precedence over other text transformations that occur
during parsing.
verb_noun_prep: []
Looks for a verb and a preposition separated by a noun, such as lock chest up.
Expand for an example
lockUp
verb_noun_prep: ["lock up"]
lock chest up
lockUp chest
verb_prep_noun: []
Looks for a verb and a preposition preceding a noun, such as look in desk.
Expand for an example
lookIn
verb_prep_noun: ["look in"]
look in desk
lookIn desk
verb_noun_prep_noun: []
Looks for a verb and a single preposition that falls between two nouns, such as ask grocer about eggplant.
Expand for an example
ask_about
verb_noun_prep_noun: ["ask about"]
ask grocer about eggplant
ask_about grocer eggplant
verb_prep_prep_noun: []
Looks for a verb and two prepositions before a noun, such as get out of boat.
Expand for an example
go_out
verb_prep_prep_noun: ["get out of"]
get out of boat
go_out boat
verb_noun_prep_prep_noun: []
Looks for a verb and two prepositions between two nouns, such as take skateboard from under bed.
Expand for an example
take_from
verb_noun_prep_prep_noun: ["take from under", "take from behind"]
take skateboard from under bed
take_from skateboard bed
verb_prep_noun_prep_noun: []
Looks for a verb and two nouns, each preceded by a preposition, such as jump from branch to vine.
Expand for an example
jumpFrom_to
verb_prep_noun_prep_noun: ["jump from to"]
jump from branch to vine
jumpFrom_to branch vine
verb_prep_prep_prep_noun: []
Looks for a verb and three prepositions followed by a noun, such as go out from behind boulder.
Expand for an example
go_out_from_behind
verb_prep_prep_prep_noun: ["go out from behind"]
get out from behind boulder
go_out_from_behind boulder
verb_noun_prep_noun_prep_noun: []
Looks for a verb and three nouns, with prepositions preceding the second and third nouns, such as tie dog to tree with rope.
Expand for an example
tie_to_with
verb_noun_prep_noun_prep_noun: ["tie to with"]
tie dog to tree with rope
tie_to_with dog tree rope
verb_prep_noun_prep_noun_prep_noun: []
Looks for a verb and three nouns, each preceded by a preposition, such as swing from tree to stalactite on vine.
Expand for an example
swing_from_to_on
verb_prep_noun_prep_noun_prep_noun: ["swing from to on"]
swing from tree to stalactite on vine
swing_from_to_on tree stalactite vine