[DGD] Working with parse_string()

bart at wotf.org bart at wotf.org
Mon Jul 20 23:38:42 CEST 2009


Hi Kamil,

>From a quick glance, your grammer is ambigious and can parse your example
sentence in 2 ways:

give 'heavy steel axe' 'nonexistant mob'

and

give 'heavy steel' 'axe nonexistant mob'

Obviously, the later makes little sense, and gets invalidated as soon as it
tries to find heavy steel.

parse_string will try both ways, which is what you are seeing in your log.

Bart.

On Mon, 20 Jul 2009 23:12:39 +0200, Kamil N wrote
> Thanks everyone for your hints, with your help I'm making some
> progress with parser for this horrible grammar :) But I found one
> strange thing happening with certain number of words involved:
> 
> separator = /[i,]/
> word = /[a-zA-Z]+/
> whitespace = / +/
> number = /[0-9]+/
> 
> verb: 'give' OBJI_ACC LIV_DAT                     ? 
> parse_give_command LIV_DAT:    DAT SELECTOR ?      find_living 
> OBJI_ACC: ACC SELECTOR ?      find_inventory
> 
> ACC: ? accusative
> DAT: ? dative
> 
> SELECTOR: OBJ                   ? parse_selector
> OBJ: ADJ ADJ word
> OBJ: ADJ word
> OBJ: word
> 
> ADJ: word
> 
> So with this grammar and my find_* functions set up so they return
> either object found or nil (if nothing can be found), I'm running 
> into strange behaviour, only using certain number of words:
> 
> give heavy steel axe nonexistant mob
> 
> HEAVY STEEL AXE exists, NONEXISTANT MOB doesnt
> 
> (I'm writing sentences in English, but they're actually Polish,
>  doesnt matter that much, and easier for you to read).
> 
> This is what my parsing logger registers when parsing is done on 
> this phrase:
> 
> -----------parse_selector:  - ({ "heavy", "steel", "axe" })
> searching in inventory - ({ ({ "accusative" }), "heavy", "steel",
>  "axe" }) FOUND:  - "heavy steel axe"
> -----------
> found is logged in LPC function just before it does return ({
> heavy_steel_axe_obj }), so if I understand parsing correctly, it 
> means that tokens "heavy", "steel" and "axe" are used now and should 
> not appear again
> 
> -----------parse_selector:  - ({ "nonexistant", "mob" })
> searching live - ({ ({ "dative" }), "nonexistant", "mob" })
> NOT FOUND:  - ({ "nonexistant", "mob" })
> 
> -----------parse_selector:  - ({ "heavy", "steel" })
> searching in inventory - ({ ({ "accusative", 1 }), "heavy", "steel" 
> }) NOT FOUND:  - ({ "heavy", "steel" })
> 
> You can see that first it does parse for OBJI and finds it, then it
> searches for LIV and can't find it but suddenly it again searches for
> "heavy" and "steel" as if it hasn't found it already. Is it normal
> behaviour or I messed something really badly? Maybe my grammar rules
> are incorrect or I return wrong values in LPC functions that cause
> this.
> 
> Is it possible for single rule "verb: 'give' OBJI_ACC LIV_DAT" to
> first look for OBJI_ACC, then for LIV_DAT and then again OBJI_ACC?
> 
> Also note that it only happens when I use exactly 5 words in my
> phrase, that is 3 words for ITEM and 2 words for LIVING.
> 
> Regards,
> KN
> ___________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd


--
Created with Open WebMail at http://www.bartsplace.net/
Read my weblog at http://soapbox.bartsplace.net/




More information about the DGD mailing list