%%% A SIMPLE GRAMMAR FOR A FRAGMENT OF ESPERANTO % NOTE: cx/gx/sx means c/g/s with circumflex. % NOTE: Since Prolog won't let us use the suffix -is % (for understandable reasons), we use s-suffix instead of -suffix % for morphology suffixes here. % THE GRAMMAR RULES % The order of constituents is free in Esperanto, but there % is such a thing as a "dominant order". We enforce this order % here, ruling out all other ones. Besides the obvious % disadvantage of understanding less, this has the advantage % of keeping us from creating weird sentences. % sentences sP(M) --> s1P(M). sP(because(M1,M2)) --> s1P(M1), [cxar], s1P(M2). s1P(M2) --> npP(M1,subject), vpP(M1,M2). % noun phrases npP(M1,C) --> np1P(M1,C). npP((M1,M2),C) --> np1P(M1,C), [kiu], vpP(M1,M2). % relative clause % simple noun phrases np1P(a(A,M1),C) --> nounP(M1,A,C). np1P(the(A,M1),C) --> [la], nounP(M1,A,C). np1P((a(A,M2),M1),C) --> adjP(M1), suffixP(A,C), nounP(M2,A,C). np1P((the(A,M2),M1),C) --> [la], adjP(M1), suffixP(A,C), nounP(M2,A,C). np1P((the(s3,name(M2)),M1),C) --> [la], adjP(M1), suffixP(s3,C), nameP(M2). np1P(M1,C) --> pronounP(M1), suffixP(s3,C). % no plural suffix np1P(name(M1),_) --> nameP(M1). % verb phrases % Following are rules for intransitive verbs, verbs with one NP complement, % verbs with an adjective complement and verbs with two complements. vpP(S,[M1,S]) --> vp1P(M1,-none). vpP(S,[M1,S,M2]) --> vp1P(M1,-np:C), npP(M2,C). vpP(S,[M1,S,M2]) --> vp1P(M1,-ap), adjP(M2). vpP(S,[M1,S,M2,M3]) --> vp1P(M1,-pp-np:C:D), [C], npP(M2,subject), npP(M3,D). % base verb phrases (in the four tenses required) vp1P((pres,M1),Objects) --> verbP(M1,Objects), ['as']. vp1P((past,M1),Objects) --> verbP(M1,Objects), ['is']. vp1P((perf,M1),Objects) --> verbP(M1,Objects), ['is']. vp1P((plus,M1),Objects) --> verbP(M1,Objects), ['is']. % Note: Esperanto *does* have participles and complex tenses. % However, they are not used in the same context as in other % languages, and it is ok to translate perfect and plusquamperfect % like past tense. % THE LEXICON % verbs (we give the root form, which is base form minus suffix "-i") verbP(see1,-np:object) --> [vid]. verbP(sleep1,-none) --> [dorm]. verbP(give1,-pp-np:al:object) --> [don]. verbP(be1,-ap) --> [est]. verbP(be1,-np:subject) --> [est]. % pronouns pronounP(me1) --> [mi]. pronounP(you1) --> [vi]. pronounP(he1) --> [li]. pronounP(she1) --> [sxi]. pronounP(it1) --> [gxi]. pronounP(we1) --> [ni]. pronounP(you2) --> [vi]. pronounP(you3) --> [vi]. pronounP(they1) --> [ili]. pronounP(they2) --> [ili]. % adjectives adjP(blue1) --> [blua]. adjP(wonderful1) --> [mirinda]. adjP(beautiful1) --> [bela]. adjP(small1) --> [malgranda]. adjP(old1) --> [maljuna]. % nouns nounP(M,A,C) --> lnounP(M), suffixP(A,C). nounP(cellularphone1,A,C) --> [cxela], suffixP(A,C), [telefono], suffixP(A,C). lnounP(woman1) --> [virino]. lnounP(man1) --> [viro]. lnounP(check1) --> [cxeko]. % names nameP(eva) --> [eva]. nameP(uta) --> [uta]. nameP(bob) --> [bob]. nameP(uwe) --> [uwe]. %% MORPHOLOGY suffixP(s3,subject) --> []. suffixP(p3,subject) --> ['j']. suffixP(s3,object) --> ['n']. suffixP(p3,object) --> ['jn']. %% EVALUATION % The following is needed to solve a problem caused by the combination of % relative sentences ("the man _who_sleeps_ is cool") and the production % of meanings of sentences by passing the meaning of the NP as a parameter % to the VP. When synthesizing sentences from the meanings, the npP rules % are called with all variables unbound, and with relative sentences this % leads to infinite loops. The block declaration states that the npP rules % are called only when either the meaning or the sequence of sentences % is bound to something. :- block npP(-,?,-,?). %% Example queries % ?- sP(M,[mi,dorm,sas,cxar,mi,est,sas,maljuna],[]). % ?- sP([(pres,see1),name(bob),((the(s3,name(eva)),beautiful1),[(pres,give1), % (the(s3,name(eva)),beautiful1),me1,a(s3,cellularphone1)])], S, []).