|
sloth.greengatherings.com |
|
Talking mobs - Grammar Documentation |
Updated November 30, 2006 |
|
Questions & Answers Future Functionality Grammar Documentation |
1. Format of the grammar files: Ancillary bits
The grammar used by the mobs is found in the .txt files in the subdirectory grammar/ of the source directory. (Note that the grammar files used by the live game are actually in live/lib/data/grammar, but the "cpmud" script copies the current grammar files from the source directory over the in-game ones - so only edit the files in the source directory, otherwise you'll lose your changes next cpmud!).
There are a few special symbols used in these files:
[word] means that "word" is optional and can be omitted (word|other) means that either "word" or "other" in this position will match this whatever-it-is <tag> indicates a tag. More on tags below. This is NOT a word that the phrase must match *alias* indicates an alias. Aliases are defined at one point in questions.txt (*alias*) is the more usual way aliases appear {extended-alias} used for aliases with multiple forms #comment # must be the first character on the line; this is how you make comments $m etc. pronouns; follow the usual system for act_c commands in the code. $m = him/her, $e = he/she, $s = his/her, $n = the full name of the person. Capital versions indicate the second person mentioned, if any. $1, $2, etc. string arguments; these are generated by the special code for each question
First come the "ignore" lines. They indicate a word that should be ignored in all communications coming from you. Even if it's ignored, this word may carry flavor, which you indicate on the ignore line with a tag. For example, ignore please <polite>
This line means that any uses of the word "please" are stripped out of your speech, but if you say something with a "please" in it, what you said acquires the <polite> tag which may affect how the monster responds. These are in ignore.txt. Next come the "transform" lines. These indicate a single word that should be transformed into one or more words. You should only include "transform" lines when something will ABSOLUTELY ALWAYS obey the given transform. For example, transform I'm I am means that "I'm" always gets parsed as "I am". This is safe because there isn't anything else the speaker might mean by "I'm". These are found in synonyms.txt. Note that transforms and ignores and such-like are only applied to parsing questions, they aren't applied to responses, which come out as written. Next come the honorifics. Words classified as honorifics are coupled with the names of a mob to make an address. Addresses can occur anywhere in a string uttered by the speaker (you) and are important to starting and ending conversations, as well as politeness. Honorifics can have arbitrary tags plus some special tags: - <male> and <female> honorifics are insulting to mobs of the opposite gender - <familiar> honorifics are very informal and may offend strangers. An example: honorific dude <familiar> <male> This example would mean that if you say Dude! Do you know where I can find some good fishing? The mob would interpret the "Dude!" as an address. The list of honorifics is in honorifics.txt. After the honorifics come aliases. By convention alias names always start and end with *, like "*bad*". Aliases are a shorthand form for something longer. For example alias *see* see|run into|encounter|spot|notice means that if I say (*see*) somewhere later in the file, I really mean (see|run into|encounter|spot|notice). Try to give aliases short, clear names. There can also be more complex aliases with multiple forms defined. These are called extended aliases and are present in the aliases.txt file just after the regular aliases. An extended alias is defined with the "extended_alias" keyword, and has a name like an alias. It is defined like this: extended_alias {I-don't-know} form [I] (dunno|don't know) form [I have] no (idea/clue) That means any time the string {I-don't-know} is encountered elsewhere, it can expand to any of: "dunno", "don't know", "I dunno", "I don't know", "I have no idea", etc. The curly brackets {} are required around the identifier. Both aliases and extended aliases are in the file aliases.txt in the grammar/ directory. Next we shall examine the decorations. Decorations are chunks of text that might be present before any question, like "Do you know" or "I wonder". Decorations can have associated tags; there is one special decoration tag, <inverse>, which means that a following question might be in an inverse form. For example, the question "where can I go fishing" has an inverse form "where I can go fishing", as in "I wonder where I can go fishing". Also, the tag <question> means that this decoration can only apply to questions, not to statements. Example decoration line: decoration (might|would|do) you [happen to] know <polite> <inverse> <question> This decoration catches such verbiage as "do you know" "might you happen to know" "would you happen to know" and only admits inverse forms, and only admits questions. Decorations are only allowed at the beginning of a question or statement. There may be more than one decoration in an utterance; in that case the tags accumulate. Two inverse tags from two inverse-ing decorations do not cancel out. Decorations are found in the file opening_phrases.txt. Next after the decorations come the phrases. Phrases are much like decorations, except that they can occur anywhere in the question and each question only allows certain phrases. Meaning-wise, phrases are more specific than decorations: decorations are just filler, but phrases generally carry some meaning, although cparse tends to ignore the meaning of the phrase and treats them as filler too. A phrase, like a question or statement, can have multiple forms. Each phrase has a number; phrases are referred to later in the questions.txt file by number. Each phrase number must be unique. For example phrase 6 easily form (calmly|coolly|easily|effortlessly) form with the greatest of ease means that any of "calmly", "coolly", "easily", "effortlessly", or |