[DGD] Working with parse_string()

Kamil N kamiln at gmail.com
Fri Jul 24 17:20:02 CEST 2009


2009/7/24  <bart at wotf.org>:
> While I don't know Polish, a little investigation turns up the following:
>
> Polish has seven cases of declination, and then seven more for the plural of a
> noun. Some of those cases look identical.
>
> On top of that, consonants at the end of a word stem often change depending on
> declination, even for regular nouns.
>
> So, it is somewhat possible to derive a case from the stem based on rules, but
> going the other way is very difficult without having some kind of lexicon.
> Humans who know the language tend to have sufficient vocabulary to recognize
> the word stem and derive what case is being used. Also, humans are somewhat
> good with patterns in a way a computer generally isn't :)

Hehe, exactly :)

> One thing I have been thinking is that you'll need to differentiate between
> invalid parsing and not being able to resolve the object.
>
> 'adjective adjective' would be a case of invalid parsing
> 'adjective noun' would be a valid parsing, regardless of being able to resolve
> this to a specific object.
>
> An object rule should contain a noun, prepended by optional adjectives.
> This would require being able to determine if a word is a noun (without trying
> to resolve it to a specific object).
>
> This would look like
>
> OBJ: opt_adjectives noun
> noun: word ? test_noun
> opt_adjectives:
> opt_adjectives: opt_adjectives adjective
> adjective: word ? test_adjective
>
> mixed * test_noun(mixed * arg) {
>  /* looks up if arg[0] is a noun */
> }
>
> etc.
>
> This all comes down to needing some kind of lexicon for lookups. You could
> build that on the fly from names used by objects in your game, or try to find
> a free one for Polish that can at least tell you if a word is a (declination
> of a) noun.

Yeah, I will be forced to have some kind of dictionary anyway to be
able to name objects properly. It will be probably filled with data
from objects that will register their names when they appear in the
world.

create() {
  set_name(({ case1, case2 .. case7 }),  /* singular */
                 ({ case1, case2 .. case7 }) }) /* plural */

}

Then object calls some DICT_D->register(names) so I can keep them all
in one place. This has already been implemented in first mudlib with
polish language support and it worked for few years

Or I can add whole declination to dictionary that will be saved to
sobe dict file and then just set name to base noun case.

create() {
   set_name(basic_noun_form);
}

Then, if needed DICT_D->query_declination(basic_noun_form);

Both approaches can be used to gather all nouns and have the
possibility to inquire for them when needed (for parsing, string
formatting etc.)

> I'd think that in order to match player input against object names, you need
> to be able to recognize the different forms of a noun that could be used by
> the player and resolve them to the object's name anyway, which would for all I
> can tell require the same information.

Yeah, whenever there is input I need to provide parser with additional
information about case. Instead of just OBJI, LIV etc. I need to give
proper noun case for that sentence, so I know in which array of
objects names I need to look (is it array of all names for case1, or
case2 etc.). It makes grammar a bit more complex because it requires
repeating of some rules just to be able to pass noun case information
all the way down to lowest LPC functions that will be doing lookup -
but its possible :)

Thanks for comments & ideas!

KN



More information about the DGD mailing list