[MUD-Dev] string parsing
Nathan Yospe
yospe at hawaii.edu
Thu Oct 30 11:36:41 CET 1997
On Thu, 30 Oct 1997, Felix A. Croes wrote:
:If you want to avoid information loss, you can let the function return
:an array, the first element of which is the original subtree, and the
:second element being the meaning that the function gives to that subtree.
:You can also use alternative grammar rules to catch user errors, for
:instance:
: GiveCommand: 'give' Object 'to' Living ? do_give
: GiveCommand: 'give' Object 'to' ZeroOrMoreWords ? give_to_whom
: GiveCommand: 'give' Object ? give_to_whom
: GiveCommand: 'give' ZeroOrMoreWords ? give_what
:The part that I didn't specify, of course, is which of these
:production rules is eventually picked: a valid give command
:matches all of them. My options seem to be to either select
:the first matching one, or to sort the resulting parse trees
:by the order of the production rules that were used to generate
:them (resulting in the "most valid" parsing being first). I
:am still undecided about this.
I've written quite a bit on this topic in the past. While my current
parsers are in Java, and the rules of the lexical system are a little
different, there are similarities... I have finally implemented sentance
completion. As soon as there is a possible completion, the completed
sentance is printed in gray text ghosted off of the typed text. Hitting
tab completes a current gray segment, hitting enter submits black only.
Sentance parse:
Give Black Bart a kick in the head.
Give Rose the rose.
Give Rose a kiss.
Give Rose to Danny.
Lightly give Rose a pat on the head. -\
Give Rose a light pat on her head. +- evaluate identically
Give Rose a pat on the head lightly. -/
Give thanks.
Five verbs match "give".
give - [subject] [noun]
give - [noun] to [subject]
give - [subject] [verb2] {othertext}
give - [subject] [verbnoun] {othertext}
give - [matching qualifier]
Where adjectives and qualifiers are considered part of the noun.
For the first one, we get:
g[rin.]
gi[ve...] <t>
give bla[ze...]
give blac[k Bart...] <t>
give Black Bart a ki[ss.]
give Black Bart a kic[k.]
give Black Bart a kick i[n the nards.]
Give Black Bart a kick in the head.
For the second:
g[rin.]
gi[ve...] <t>
give ro[se...] <t>
give Rose a ro[se.] <t>
Give Rose a rose.
For the third:
g[ive...] <t> //assuming prediction weight on give now exceeds grin
give ro[se...] <t>
give Rose a ki[ck.]
give Rose a kis[anderian helm.]
give Rose a kiss[.]
Give Rose a kiss. // => Kiss Rose.
For the fourth:
g[ive] <t>
give ro[se...] <t>
give Rose t
give rose to
give
give Rose to da[nny.]
Give Rose to Danny.
What actually happens?
The five "give" verbs are each performing a seperate weighting of the input
as it comes in. The one that evaluates the input the most sucessfully gets
chosen. In the case of a tie, the higher version of the verb (ie: give
subject noun) gets evaluated. Recent actions get a higher weighting.
--
"You? We can't take you," said the Dean, glaring at the Librarian.
"You don't know a thing about guerilla warfare." - Reaper Man,
Nathan F. Yospe Registered Looney by Terry Pratchett
yospe at hawaii.edu http://www2.hawaii.edu/~yospe Meow
More information about the mud-dev-archive
mailing list