Module Newdic

Jan Burse, created May 22. 2019
/**
* Prolog text newdic from Chat80 as a module.
*
* Warranty & Liability
* To the extent permitted by applicable law and unless explicitly
* otherwise agreed upon, XLOG Technologies GmbH makes no warranties
* regarding the provided information. XLOG Technologies GmbH assumes
* no liability that any problems might be solved with the information
* provided by XLOG Technologies GmbH.
*
* Rights & License
* All industrial property rights regarding the information - copyright
* and patent rights in particular - are the sole property of XLOG
* Technologies GmbH. If the company was not the originator of some
* excerpts, XLOG Technologies GmbH has at least obtained the right to
* reproduce, change and translate the information.
*
* Reproduction is restricted to the whole unaltered document. Reproduction
* of the information is only allowed for non-commercial uses. Selling,
* giving away or letting of the execution of the library is prohibited.
* The library can be distributed as part of your applications and libraries
* for execution provided this comment remains unchanged.
*
* Restrictions
* Only to be distributed with programs that add significant and primary
* functionality to the library. Not to be distributed with additional
* software intended to replace any components of the library.
*
* Trademarks
* Jekejeke is a registered trademark of XLOG Technologies GmbH.
*/
/**
* Obtained rights comment in Prolog text and text from LICENSE file:
*
* @(#)newdic.pl 24.1 2/23/88
*
* Copyright 1986, Fernando C.N. Pereira and David H.D. Warren,
*
* All Rights Reserved
*
* This program may be used, copied, altered or included in other programs
* only for academic purposes and provided that the authorship of the
* initial program is acknowledged. Use for commercial purposes without the
* previous written agreement of the authors is forbidden.
*/
:- if(current_prolog_flag(dialect,jekejeke)).
:- package(library(natural)).
:- endif.
:- module(newdic, [word/1,conj/1,int_pron/2,int_art/4,
det/4,number/3,quantifier_pron/3,prep/1,
noun_form/3,verb_form/4,verb_type/2,
rel_pron/2,poss_pron/4,pers_pron/5,
terminator/2,name/1,loc_pred/2,adj/2,
rel_adj/2,sup_adj/2,adverb/1,(~)/1,
check_words/2]).
:- use_module('../database/chatops').
:- use_module(templa).
:- discontiguous verb_form/4.
:- discontiguous verb_root/1.
:- discontiguous verb_type/2.
:- discontiguous regular_past/2.
:- discontiguous regular_pres/1.
:- discontiguous sup_adj/2.
:- discontiguous noun_form/3.
% Modes
% :- mode word(+).
% :- mode ~(+).
% :- mode conj(+).
% :- mode adverb(+).
% :- mode sup_adj(+,?).
% :- mode rel_adj(+,?).
% :- mode adj(+,?).
% :- mode name_template(+,-).
% :- mode name(+).
% :- mode terminator(+,?).
% :- mode pers_pron(+,?,?,?,?).
% :- mode poss_pron(+,?,?,?).
% :- mode rel_pron(+,?).
% :- mode regular_past(+,?).
% :- mode regular_pres(+).
% :- mode verb_root(+).
% :- mode verb_form(+,?,?,?).
% :- mode noun_sin(+).
% :- mode noun_plu(+,?).
% :- mode noun_form(+,?,?).
% :- mode prep(+).
% :- mode quantifier_pron(+,?,?).
% :- mode tr_number(+,?).
% :- mode number(+,?,?).
% :- mode det(+,?,?,?).
% :- mode int_art(+,?,?,?).
% :- mode int_pron(+,?).
% =================================================================
% General Dictionary
word(Word) :-
~(Word).
word(Word) :-
conj(Word).
word(Word) :-
adverb(Word).
word(Word) :-
sup_adj(Word, _).
word(Word) :-
rel_adj(Word, _).
word(Word) :-
adj(Word, _).
word(Word) :-
name(Word).
word(Word) :-
terminator(Word, _).
word(Word) :-
pers_pron(Word, _, _, _, _).
word(Word) :-
poss_pron(Word, _, _, _).
word(Word) :-
rel_pron(Word, _).
word(Word) :-
verb_form(Word, _, _, _).
word(Word) :-
noun_form(Word, _, _).
word(Word) :-
prep(Word).
word(Word) :-
quantifier_pron(Word, _, _).
word(Word) :-
number(Word, _, _).
word(Word) :-
det(Word, _, _, _).
word(Word) :-
int_art(Word, _, _, _).
word(Word) :-
int_pron(Word, _).
word(Word) :-
loc_pred(Word, _).
~ how.
~ whose.
~ there.
~ of.
~('''').
~(',').
~ s.
~ than.
~ at.
~ the.
~ not.
~(as).
~ that.
~ less.
~ more.
~ least.
~ most.
~ many.
~ where.
~ when.
conj(and).
conj(or).
int_pron(what, undef).
int_pron(which, undef).
int_pron(who, subj).
int_pron(whom, compl).
int_art(what, X, _, int_det(X)).
int_art(which, X, _, int_det(X)).
det(the, No, the(No), def).
det(a, sin, a, indef).
det(an, sin, a, indef).
det(every, sin, every, indef).
det(some, _, some, indef).
det(any, _, any, indef).
det(all, plu, all, indef).
det(each, sin, each, indef).
det(no, _, no, indef).
number(W, I, Nb) :-
tr_number(W, I),
ag_number(I, Nb).
tr_number(nb(I), I).
tr_number(one, 1).
tr_number(two, 2).
tr_number(three, 3).
tr_number(four, 4).
tr_number(five, 5).
tr_number(six, 6).
tr_number(seven, 7).
tr_number(eight, 8).
tr_number(nine, 9).
tr_number(ten, 10).
ag_number(1, sin).
ag_number(N, plu) :-
N > 1.
quantifier_pron(everybody, every, person).
quantifier_pron(everyone, every, person).
quantifier_pron(everything, every, thing).
quantifier_pron(somebody, some, person).
quantifier_pron(someone, some, person).
quantifier_pron(something, some, thing).
quantifier_pron(anybody, any, person).
quantifier_pron(anyone, any, person).
quantifier_pron(anything, any, thing).
quantifier_pron(nobody, no, person).
quantifier_pron(nothing, no, thing).
prep(as).
prep(at).
prep(of).
prep(to).
prep(by).
prep(with).
prep(in).
prep(on).
prep(from).
prep(into).
prep(through).
noun_form(Plu, Sin, plu) :-
noun_plu(Plu, Sin).
noun_form(Sin, Sin, sin) :-
noun_sin(Sin).
verb_form(V, V, inf, _) :-
verb_form(V, V, pres+fin, Agmt) :-
root_form(Agmt),
verb_form(Past, Root, past+_, _) :-
regular_past(Past, Root).
root_form(1+sin).
root_form(2+_).
root_form(1+plu).
root_form(3+plu).
verb_root(have).
verb_form(am, be, pres+fin, 1+sin).
verb_form(are, be, pres+fin, 2+sin).
verb_form(is, be, pres+fin, 3+sin).
verb_form(are, be, pres+fin, _+plu).
verb_form(was, be, past+fin, 1+sin).
verb_form(were, be, past+fin, 2+sin).
verb_form(was, be, past+fin, 3+sin).
verb_form(were, be, past+fin, _+plu).
verb_form(been, be, past+part, _).
verb_form(being, be, pres+part, _).
verb_type(be, aux+be).
regular_past(had, have).
verb_form(has, have, pres+fin, 3+sin).
verb_form(having, have, pres+part, _).
verb_type(have, aux+have).
verb_form(does, do, pres+fin, 3+sin).
verb_form(did, do, past+fin, _).
verb_form(doing, do, pres+part, _).
verb_form(done, do, past+part, _).
verb_type(do, aux+ditrans).
rel_pron(who, subj).
rel_pron(whom, compl).
rel_pron(which, undef).
poss_pron(my, _, 1, sin).
poss_pron(your, _, 2, _).
poss_pron(his, masc, 3, sin).
poss_pron(her, fem, 3, sin).
poss_pron(its, neut, 3, sin).
poss_pron(our, _, 1, plu).
poss_pron(their, _, 3, plu).
pers_pron(i, _, 1, sin, subj).
pers_pron(you, _, 2, _, _).
pers_pron(he, masc, 3, sin, subj).
pers_pron(she, fem, 3, sin, subj).
pers_pron(it, neut, 3, sin, _).
pers_pron(we, _, 1, plu, subj).
pers_pron(them, _, 3, plu, subj).
pers_pron(me, _, 1, sin, compl(_)).
pers_pron(him, masc, 3, sin, compl(_)).
pers_pron(her, fem, 3, sin, compl(_)).
pers_pron(us, _, 1, plu, compl(_)).
pers_pron(them, _, 3, plu, compl(_)).
terminator('.', _).
terminator(?, ?).
terminator(!, !).
name(Name) :-
name_template(Name, _), !.
% =================================================================
% Specialised Dictionary
loc_pred(east, prep(eastof)).
loc_pred(west, prep(westof)).
loc_pred(north, prep(northof)).
loc_pred(south, prep(southof)).
adj(minimum, restr).
adj(maximum, restr).
adj(average, restr).
adj(total, restr).
adj(african, restr).
adj(american, restr).
adj(asian, restr).
adj(european, restr).
adj(great, quant).
adj(big, quant).
adj(small, quant).
adj(large, quant).
adj(old, quant).
adj(new, quant).
adj(populous, quant).
rel_adj(greater, great).
rel_adj(less, small).
rel_adj(bigger, big).
rel_adj(smaller, small).
rel_adj(larger, large).
rel_adj(older, old).
rel_adj(newer, new).
sup_adj(biggest, big).
sup_adj(smallest, small).
sup_adj(largest, large).
sup_adj(oldest, old).
sup_adj(newest, new).
noun_form(proportion, proportion, _).
noun_form(percentage, percentage, _).
noun_sin(average).
noun_sin(total).
noun_sin(sum).
noun_sin(degree).
noun_sin(sqmile).
noun_sin(ksqmile).
noun_sin(thousand).
noun_sin(million).
noun_sin(time).
noun_sin(place).
noun_sin(area).
noun_sin(capital).
noun_sin(city).
noun_sin(continent).
noun_sin(country).
noun_sin(latitude).
noun_sin(longitude).
noun_sin(ocean).
noun_sin(person).
noun_sin(population).
noun_sin(region).
noun_sin(river).
noun_sin(sea).
noun_sin(seamass).
noun_sin(number).
noun_plu(averages, average).
noun_plu(totals, total).
noun_plu(sums, sum).
noun_plu(degrees, degree).
noun_plu(sqmiles, sqmile).
noun_plu(ksqmiles, ksqmile).
noun_plu(million, million).
noun_plu(thousand, thousand).
noun_plu(times, time).
noun_plu(places, place).
noun_plu(areas, area).
noun_plu(capitals, capital).
noun_plu(cities, city).
noun_plu(continents, continent).
noun_plu(countries, country).
noun_plu(latitudes, latitude).
noun_plu(longitudes, longitude).
noun_plu(oceans, ocean).
noun_plu(persons, person).
noun_plu(people, person).
noun_plu(populations, population).
noun_plu(regions, region).
noun_plu(rivers, river).
noun_plu(seas, sea).
noun_plu(seamasses, seamass).
noun_plu(numbers, number).
verb_root(border).
verb_root(contain).
verb_root(drain).
verb_root(exceed).
verb_root(flow).
verb_root(rise).
verb_form(rises, rise, pres+fin, 3+sin).
verb_form(rose, rise, past+fin, _).
verb_form(risen, rise, past+part, _).
regular_pres(border).
regular_past(bordered, border).
verb_form(borders, border, pres+fin, 3+sin).
verb_form(bordering, border, pres+part, _).
regular_pres(contain).
regular_past(contained, contain).
verb_form(contains, contain, pres+fin, 3+sin).
verb_form(containing, contain, pres+part, _).
regular_pres(drain).
regular_past(drained, drain).
verb_form(drains, drain, pres+fin, 3+sin).
verb_form(draining, drain, pres+part, _).
regular_pres(exceed).
regular_past(exceeded, exceed).
verb_form(exceeds, exceed, pres+fin, 3+sin).
verb_form(exceeding, exceed, pres+part, _).
verb_type(rise, main+intrans).
verb_type(border, main+trans).
verb_type(contain, main+trans).
verb_type(drain, main+intrans).
verb_type(exceed, main+trans).
regular_past(flowed, flow).
verb_form(flows, flow, pres+fin, 3+sin).
verb_form(flowing, flow, pres+part, _).
verb_type(flow, main+intrans).
adverb(yesterday).
adverb(tomorrow).
% :- mode check_words(+,-).
% :- mode check_word(+,-).
check_words([], []).
check_words([Word|Words], [RevWord|RevWords]) :-
check_word(Word, RevWord),
check_words(Words, RevWords).
check_word(Word, Word) :-
word(Word), !.
check_word(Word, NewWord) :-
write('? '),
write(Word),
write(' -> (!. to abort) '), flush_output,
read(NewWord0),
NewWord0 \== !,
check_word(NewWord0, NewWord).

Comments