Write a Prolog DCG grammar that handle the mean of a sentence and also build its parse tree -


i have dcg grammar understand , agree phrases like: [john, paints] , [john, likes, mary] managing semantic meaning directly dcg grammar use of parameters

sentence2(vp) --> noun_phrase2(actor),                   verb_phrase2(actor, vp).  noun_phrase2(name) --> propername(name).  verb_phrase2(actor, vp) --> intrans_verb(actor, vp).  verb_phrase2(somebody, vp) --> trans_verb(somebody, something, vp),                                noun_phrase2(something).  propername(john) --> [john]. propername(mary) --> [mary].  intrans_verb(actor, paints(actor)) --> [paints].  trans_verb(somebody, something, likes(somebody, something)) --> [likes]. 

for example mean of phrase [john, paints] be: paints(john), infact result of query:

?- sentence2(meaning, [john,paints],[]). meaning = paints(john)  

ok, handle meaning without build parse tree.

i have exercise ask me modify previous grammar obtain mean syntattic tree of sentence. queries have return parse tree, , meaning of sentence

but finding problem doing it...i trying this, don't work:

/** adding meaning parse tree: */  sentence2(sentence(name, verbphrase)) --> noun_phrase2(name),                                   verb_phrase2(verbphrase).  noun_phrase2(noun_phrase(name)) --> propername2(name).   verb_phrase2(verb_phrase(intransverb)) --> intrans_verb2(intransverb).  verb_phrase2(verb_phras(transverb, propername)) --> trans_verb2(transverb),                                     noun_phrase2(propername).  /* propername, intrans_verb ant trans_verb leaves: */ propername2(propername(john)) --> [john].  propername2(propername(mary)) --> [mary].  intrans_verb2(actor, intrans_verb2(paints(actor))) --> [paints].  trans_verb2(somebody, something, trans_verb2(likes(somebody, something))) --> [likes]. 

i think question ill-posed. if say

?- sentence2(meaning, [john,paints], []). meaning = paints(john). 

you're saying result of parse "meaning" , not parse tree. expect parse tree more this:

parse = s(np(propernoun(john)), vp(intrans(paints))). 

you can produce parse trees augmenting dcg structural information:

sentence(s(nounphrase, verbphrase)) -->      noun_phrase(nounphrase),      verb_phrase(verbphrase).  noun_phrase(proper_noun(john))    --> [john]. verb_phrase(intransitive(paints)) --> [paints]. 

if want 1 or other, generate 1 want. if want both, should collect meaning after parse using tree. otherwise there's not point getting parse tree, there? here's sketch:

meaning(s(proper_noun(noun), intransitive(verb)), meaning) :-   meaning =.. [verb, noun]. 

this of course have made more robust, how might used:

?- phrase(sentence(s), [john, paints]), meaning(s, meaning). s = s(proper_noun(john), intransitive(paints)), meaning = paints(john). 

now explore, play! make parses of native language (italian, right?) "meaningful" structures. parse few sentences of turkish "meaning" , generate italian it. you'll surprised how comes together.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -