:- module(toaq, [toaq_parser/2]). toaq_parser(In, Out) :- atom_codes(In,Codes), phrase(discourse(Out), Codes), drucke_baum(Out). toaq_parser(_In, 'Not grammatical.'). ~ --> " ". match(Rule, Codes, In, Out):- phrase(Rule, In, Out), append(Codes, Out, In). /* Discourse */ discourse(discourse(Dis_Unit,Discourse)) --> ( discourse_unit(Dis_Unit) , ~ , discourse(Discourse) ). discourse(discourse(Dis_Unit)) --> discourse_unit(Dis_Unit). discourse_unit(d_unit(S_prefix,S)) --> sentence_prefix(S_prefix) , ~ , sentence(S). discourse_unit(S) --> sentence(S). /* discourse_unit(d_unit(S)) --> non_sentence(S). discourse_unit(d_unit(S_prefix,S)) --> sentence_prefix(S_prefix) , ~ , non_sentence(S). */ /* Sentences */ sentence_prefix(Atom) --> match(sentence_prefix_word,Codes), { atom_codes(Atom,Codes) }. sentence_prefix_word --> "ma" , "sa". sentence(s(P,Illoc)) --> predication(P) , ~ , illoc(Illoc). sentence(s(P,illoc(Illoc,Free))) --> predication(P) , ~ , illoc(Illoc) , ~ , freemods(Free). sentence(s(Prenex,S)) --> prenex(Prenex) , ~ , sentence(S). prenex(prenex(Start,Terms)) --> prenex_start(Start) , ~ , terms(Terms). prenex(prenex(prenex_start(Start,Free),Terms)) --> prenex_start(Start) , ~ , terms(Terms) , ~ , freemods(Free). prenex_start(prenex_start(bi)) --> "bi". predication(predication(Predicate,Terms)) --> predicate(Predicate) , ~ , terms(Terms). predication(predication(Predicate)) --> predicate(Predicate). /* non_sentence(non_s(Prenex)) --> prenex(Prenex). non_sentence(non_s(Terms)) --> terms(Terms). */ /* Predicates */ predicate(Predicate) --> predicate_1(Predicate). predicate_1(Predicate) --> predicate_2(Predicate). predicate_1(predicate(Predicate,PredConP)) --> predicate_2(Predicate) , ~ , predicateConP(PredConP). predicate_2(predicate(Predicate)) --> predicate_word(predicate(Pred)) , "-" , { atom_concat(Pred, (-) , Predicate) }. predicate_2(predicate(Predicate,Free)) --> predicate_word(predicate(Pred)) , "-" , { atom_concat(Pred, (-) , Predicate) } , ~ , freemods(Free). predicate_2(predicates(Predicate,Predicates)) --> predicate_word(predicate(Pred)) , "-" , { atom_concat(Pred, (-) , Predicate) } , ~ , predicates(Predicates). predicate_2(predicates(predicate(Predicate,Free),Predicates)) --> predicate_word(predicate(Pred)) , "-" , { atom_concat(Pred, (-) , Predicate) } , ~ , freemods(Free) , ~ , predicates(Predicates). predicate_2(predicate(namifier(N),Pred)) --> namifier(X) , "-" , { atom_concat((X), (-) , N) }, ~ , predicate(Pred). predicateConP(predicateConP(Con,Pred)) --> connective(Con) , ~ , predicate(Pred). predicates(X) --> predicate(X). predicates(predicates(X,Y)) --> predicate(X), ~ , predicates(Y). namifier(Atom) --> match(namifier_word, Codes), { atom_codes(Atom, Codes) }. namifier_word --> "mi". /* Terms */ terms(terms(Term,Terms)) --> term(Term) , ~ , terms(Terms). terms(Term) --> term(Term). term(term(Term)) --> argument(Term). term(term(Term)) --> adverb(Term). term(term(Term)) --> prepositional_phrase(Term). term(term(Term)) --> soi_clause(Term). term(Term) --> termset(Term). /* Arguments */ argument(Argument) --> arg_1(Argument). argument(argument(Arg1,Arg2)) --> arg_1(Arg1,Arg2). arg_1(Arg) --> arg_2(Arg). arg_1(Arg,ArgConP) --> arg_2(Arg) , ~ , argConP(ArgConP). arg_2(quantified(Quantifier,Arg)) --> quantifier(Quantifier) , ~ , arg_3(Arg). arg_2(Arg) --> arg_3(Arg). arg_3(argument(Arg, Rel)) --> arg_4(Arg) , ~ , rel_sentence(Rel). arg_3(Arg) --> arg_4(Arg). arg_4(argument(Arg)) --> pronoun(pronoun(Pred)), "/" , { atom_concat(Pred, (/) , Arg) }. arg_4(argument(Arg,Free)) --> pronoun(pronoun(Pred)), "/" , { atom_concat(Pred, (/) , Arg) } , ~ , freemods(Free). arg_4(argument(Arg)) --> predicate_word(predicate(Pred)), "/" , { atom_concat(Pred, (/) , Arg) }. arg_4(argument(Arg,Free)) --> predicate_word(predicate(Pred)), "/" , { atom_concat(Pred, (/) , Arg) } , ~ , freemods(Free). arg_4(argument(Arg,Predicates)) --> predicate_word(predicate(Pred)), "/" , { atom_concat(Pred, (/) , Arg) } , ~ ,predicates(Predicates). argConP(argConP(Con, Arg)) --> connective(Con), ~ , argument(Arg). connective(conjunction(Atom)) --> match(connective_word, Codes), { atom_codes(Atom, Codes) }. connective(conjunction(Atom,Free)) --> match(connective_word, Codes), { atom_codes(Atom, Codes) }, ~ , freemods(Free). connective_word --> "ra" ; "re" ; "ri" ; "ro" ; "ru". pronoun(pronoun(Atom)) --> match(pronoun_word, Codes), { atom_codes(Atom, Codes) }. pronoun_word --> "gou" ; "teq" ; "hoa" ; "de". /* Relative Clauses */ rel_sentence(rel_s(P,Illoc)) --> rel_predication(P) , ~ , illoc(Illoc). rel_sentence(rel_s(P,illoc(Illoc,Free))) --> rel_predication(P) , ~ , illoc(Illoc) , ~ , freemods(Free). rel_sentence(rel_s(Prenex,S)) --> rel_prenex(Prenex) , ~ , sentence(S). rel_prenex(prenex(Start,Terms)) --> rel_prenex_start(Start) , ~ , terms(Terms). rel_prenex(prenex(Start,Terms)) --> rel_prenex_start(Start) , ~ , terms(Terms). rel_prenex_start(prenex_start('bi?')) --> "bi?". rel_prenex_start(prenex_start(prenex_start('bi?'),Free)) --> "bi?" , ~ , freemods(Free). rel_predication(predication(Predicate)) --> rel_pred(Predicate). rel_predication(predication(Predicate,Terms)) --> rel_pred(Predicate) , ~ , terms(Terms). rel_pred(predicate(RelPredicate)) --> predicate_word(predicate(Predicate)) , "?" , { atom_concat(Predicate , (?) , RelPredicate) }. rel_pred(predicate(RelPredicate,Free)) --> predicate_word(predicate(Predicate)) , "?" , { atom_concat(Predicate , (?) , RelPredicate) } , ~ , freemods(Free). rel_pred(predicate(RelPredicate,Predicates)) --> predicate_word(predicate(Predicate)) , "?" , { atom_concat(Predicate , (?) , RelPredicate) } , ~ , predicates(Predicates). rel_pred(predicate(predicate(RelPredicate,Free),Predicates)) --> predicate_word(predicate(Predicate)) , "?" , { atom_concat(Predicate , (?) , RelPredicate) } , ~ , freemods(Free) , ~ , predicates(Predicates). /* Termsets */ termset(Termset) --> termset1(Termset). termset(Termset) --> termset2(Termset). termset(Termset) --> termset3(Termset). termset_head(Head) --> "to" , ~ , connective(conjunction(Connective)) , { atom_concat('to ', Connective , Head) }. termset_head(termset_head(Head,Free)) --> "to" , ~ , connective(conjunction(Connective)) , { atom_concat('to ', Connective , Head) } , ~ , freemods(Free). termset_tail_head(to) --> "to". termset_tail_head(to(to,Free)) --> "to" , ~ , freemods(Free). /* Termset 1 */ termset1(termset(Left,Right)) --> left1(Left) , ~ , right1(Right). left1(left(Head,Terms)) --> termset_head(Head) , ~ ,terms1(Terms). right1(right(Head,Terms)) --> termset_tail_head(Head) , ~ , terms1(Terms). terms1(terms(Term)) --> term(Term). /* Termset 2 */ termset2(termset(Left,Right)) --> left2(Left) , ~ , right2(Right). left2(left(Head,Terms)) --> termset_head(Head) , ~ ,terms2(Terms). right2(right(Head,Terms)) --> termset_tail_head(Head) , ~ , terms2(Terms). terms2(terms(Term,Terms)) --> term(Term) , ~ , terms1(Terms). /* Termset 3 */ termset3(termset(Left,Right)) --> left3(Left) , ~ , right3(Right). left3(left(Head,Terms)) --> termset_head(Head) , ~ ,terms3(Terms). right3(right(Head,Terms)) --> termset_tail_head(Head) , ~ , terms3(Terms). terms3(terms(Term,Terms)) --> term(Term) , ~ , terms2(Terms). /* Adverbs */ adverb(Adverb) --> adverb_1(Adverb). adverb_1(Adverb) --> adverb_2(Adverb). adverb_1(adverb(Adverb,ConP)) --> adverb_2(Adverb) , ~ , adverbConP(ConP). adverb_1(adverb(adverb(Adverb,Free),ConP)) --> adverb_2(Adverb) , ~ , freemods(Free) , ~ , adverbConP(ConP). adverb_2(adverb(Adverb)) --> predicate_word(predicate(Predicate)), "~", { atom_concat(Predicate, (~) , Adverb) }. adverb_2(adverb(Adverb,Free)) --> predicate_word(predicate(Predicate)), "~", { atom_concat(Predicate, (~) , Adverb) } , ~ , freemods(Free). adverb_2(adverb(Adverb,Predicates)) --> predicate_word(predicate(Predicate)), "~", { atom_concat(Predicate, (~) , Adverb) } , ~ , predicates(Predicates). adverb_2(adverb(adverb(Adverb,Free),Predicates)) --> predicate_word(predicate(Predicate)), "~", { atom_concat(Predicate, (~) , Adverb) } , ~ , freemods(Free) , ~ , predicates(Predicates). adverbConP(adverbConP(Con,Adv)) --> connective(Con), ~ , adverb(Adv). /* Prepositions */ prepositional_phrase(pp(P,S)) --> preposition_s(P) , ~ , sentence(S). prepositional_phrase(pp(P,A)) --> preposition_n(P) , ~ , argument(A). preposition_s(P) --> preposition_s_1(P). preposition_s_1(P) --> preposition_s_2(P). preposition_s_1(p(P,PConP)) --> preposition_s_2(P) , ~ , preposition_s_ConP(PConP). preposition_s_2(p(P)) --> predicate_word(predicate(Predicate)), "\\" , { atom_concat(Predicate, (\) , P) }. preposition_s_2(p(P,Free)) --> predicate_word(predicate(Predicate)), "\\" , { atom_concat(Predicate, (\) , P) } , ~ , freemods(Free). preposition_s_2(p(P,Predicates)) --> predicate_word(predicate(Predicate)), "\\" , { atom_concat(Predicate, (\) , P) }, ~ , predicates(Predicates). preposition_s_2(p(P,Free),Predicates) --> predicate_word(predicate(Predicate)), "\\" , { atom_concat(Predicate, (\) , P) }, ~ , freemods(Free) , ~ , predicates(Predicates). preposition_s_ConP(pConP(Con, Preposition)) --> connective(Con) , ~ , preposition_s(Preposition). preposition_n(P) --> preposition_n_1(P). preposition_n_1(P) --> preposition_n_2(P). preposition_n_1(p(P, PConP)) --> preposition_n_2(P) , ~ , preposition_n_ConP(PConP). preposition_n_2(p(P)) --> predicate_word(predicate(Predicate)), "^" , { atom_concat(Predicate, (^) , P) }. preposition_n_2(p(P,Free)) --> predicate_word(predicate(Predicate)), "^" , { atom_concat(Predicate, (^) , P) } , ~ , freemods(Free). preposition_n_2(p(P,Predicates)) --> predicate_word(predicate(Predicate)), "^" , { atom_concat(Predicate, (^) , P) } , ~ , predicates(Predicates). preposition_n_2(p(P,Free),Predicates) --> predicate_word(predicate(Predicate)), "^" , { atom_concat(Predicate, (^) , P) } , ~ , freemods(Free) , ~ , predicates(Predicates). preposition_n_ConP(pConP(Con, Preposition)) --> connective(Con) , ~ , preposition_n(Preposition). /* Sentence Restrictive Clauses */ soi_clause(s_rel(P,S)) --> soi(P) , ~ , sentence(S). soi(P) --> soi_1(P). soi_1(P) --> soi_2(P). soi_1(r(P,SoiConP)) --> soi_2(P) , ~ , soiConP(SoiConP). soi_2(r(P)) --> predicate_word(predicate(Predicate)), "°" , { atom_concat(Predicate, (°) , P) }. soi_2(r(P,Free)) --> predicate_word(predicate(Predicate)), "°" , { atom_concat(Predicate, (°) , P) } , ~ , freemods(Free). soi_2(r(P,Predicates)) --> predicate_word(predicate(Predicate)), "°" , { atom_concat(Predicate, (°) , P) }, ~ , predicates(Predicates). soi_2(r(P,Free),Predicates) --> predicate_word(predicate(Predicate)), "°" , { atom_concat(Predicate, (°) , P) }, ~ , freemods(Free) , ~ , predicates(Predicates). soiConP(rConP(Con,Preposition)) --> connective(Con) , ~ , soi(Preposition). /* Illocutionary Operators */ illoc(Illoc) --> illoc_1(Illoc). illoc_1(Illoc) --> illoc_2(Illoc). illoc_1(illoc(Illoc, IllocConP)) --> illoc_2(Illoc), ~ , illocConP(IllocConP). illoc_2(Illoc) --> illoc_word(Illoc). illocConP(illocConP(Con, Illoc)) --> connective(Con), ~ , illoc(Illoc). illoc_word(illoc(Atom)) --> match(illoc_word_entry, Codes), { atom_codes(Atom, Codes) }. illoc_word_entry --> "na" ; "pu" ; "ci" ; "moq". /* Connectives */ %connective(conj(ru)) --> "ru". /* Parentheticals / Incidental Clauses */ parenthetical(parenthetical(ju,S)) --> "ju" , ~ , sentence(S). parenthetical(parenthetical(ju(ju,Free),S)) --> "ju" , ~ , freemods(Free) , ~ , sentence(S). parenthetical(parenthetical(kio,DKi)) --> "kio" , ~ , discourse_ki(DKi). parenthetical(parenthetical(kio(kio,Free),DKi)) --> "kio" , ~ , freemods(Free) , ~ , discourse_ki(DKi). discourse_ki(discourse(D,ki)) --> discourse(D) , ~ , "ki". /* Interjections and Free Modifiers */ freemod(interjection(X)) --> interjection(X). freemod(X) --> parenthetical(X). freemods(A) --> freemod(A). freemods(freemods(A,B)) --> freemod(A), ~ , freemods(B). interjection(Atom) --> match(interjection_word, Codes), { atom_codes(Atom, Codes) }. interjection_word --> "ha". /* Math Expressions */ quantifier(quantifier(Mex)) --> mex(Mex). mex(Mex) --> mex_1(Mex). mex_1(Digits) --> digits(Digits). mex_1(mex(Digits,ConP)) --> digits(Digits) , ~ , digitsConP(ConP). digits(Digit) --> digit(Digit). digits(digits(Digit,Digits)) --> digit(Digit) , ~ , digits(Digits). digitsConP(digitsConP(Con,Digits)) --> connective(Con) , ~ , digits(Digits). digit(Atom) --> match(digit_word, Codes), { atom_codes(Atom, Codes) }. digit(digit(Atom,Free)) --> match(digit_word, Codes), { atom_codes(Atom, Codes) } , ~ , freemods(Free). digit_word --> "niq" ; "hua" ; "raq" ; "buo" ; "he" ; "djiu" ; "dro" ; "nae" ; "soq" ; "sia". /* Morphology */ predicate_word(predicate(Atom)) --> match(syllable, Codes), { atom_codes(Atom, Codes), \+ phrase(particle,Codes) }. particle --> "na";"niq";"hua";"raq";"buo";"he";"djiu";"dro";"nae";"soq";"sia"; "ha";"to";"bi";"gou";"teq";"hoa";"ra";"re";"ri";"ro";"ru";"moq"; "ci";"sa";"ma";"pu";"mi";"fi". syllable --> onset, rhyme. onset --> consonant. onset --> consonant_cluster. rhyme --> nucleus. rhyme --> nucleus, coda. nucleus --> vowel. nucleus --> diphthong. coda --> q. consonant --> b ; c ; d ; f ; g ; h ; j ; k ; l ; m ; n ; p ; r ; s ; t ; v ; z. consonant_cluster --> ( b ; d ; g ; p ; t ; k ; v ; f ) , ( r ; l ) ; t , (c;s) ; d , (j;z) ; ( c ; s ) , ( p ; t ; k ; m ; n ) ; ( j ; z ) , ( b ; d ; g ) ; ( b ; d ; g ; p ; t ; k ; c ; s ; j ; z ) , w ; b , y . vowel --> a ; e ; i ; o ; u. diphthong --> vowel, vowel. a --> "a". b --> "b". c --> "c". d --> "d". e --> "e". f --> "f". g --> "g". h --> "h". i --> "i". j --> "j". k --> "k". l --> "l". m --> "m". n --> "n". o --> "o". p --> "p". q --> "q". r --> "r". s --> "s". t --> "t". u --> "u". v --> "v". w --> "w". y --> "y". z --> "z".