Интерфейс на естественном языке. Семантический анализ, страница 2

composite_query("","Brigade","","","",Lab) :- !,

brigade_lab(X,Lab),

write(X," has defended ",Lab,"."),nl,

fail.

% Mixed queries of second order with unknown variable.

composite_query("Who","",Sex,Year1,When,"") :- !,

def_sex(Sex,S),

person_sex(X,S),

person_birthday(X,Year2),

def_when(Year1,Year2,When),

write(X," is a ",Sex," and was born ",When," ",Year1,"."),nl,

fail.

composite_query("Who",Brigade,"",Year1,When,"") :- !,

person_brigade(X,Brigade),

person_birthday(X,Year2),

def_when(Year1,Year2,When),

write(X," consist in ",Brigade," and was born ",When," ",Year1,"."),nl,

fail.

composite_query("Who",Brigade,"","","",Lab) :- !,

person_brigade(X,Brigade),

brigade_lab(Brigade,Lab),

write(X," consist in ",Brigade,", that has defended ",Lab,"."),nl,

fail.

composite_query("Who",Brigade,Sex,"","","") :- !,

def_sex(Sex,S),

person_sex(X,S),

person_brigade(X,Brigade),

write(X," is a ",Sex," and consist in ",Brigade,"."),nl,

fail.

% Mixed queries of third order with unknown variable.

composite_query("Who",Brigade,Sex,Year1,When,"") :- !,

person_birthday(X,Year2),

def_when(Year1,Year2,When),

def_sex(Sex,S),

person_sex(X,S),

person_brigade(X,Brigade),

write(X," is a ",Sex," and was born ",When," ",Year1," and consist in ",Brigade,"."),nl,

fail.

composite_query("Who",Brigade,"",Year1,When,Lab) :- !,

person_birthday(X,Year2),

def_when(Year1,Year2,When),

person_brigade(X,Brigade),

brigade_lab(Brigade,Lab),

write(X," was born ",When," ",Year1," and consist in ",Brigade,", that has defended ",Lab,"."),nl,

fail.

composite_query("Who",Brigade,Sex,"","",Lab) :- !,

def_sex(Sex,S),

person_sex(X,S),

person_brigade(X,Brigade),

brigade_lab(Brigade,Lab),

write(X," is a ",Sex," and consist in ",Brigade,", that has defended ",Lab,"."),nl,

fail.

% Mixed queries of fourth order with unknown variable.

composite_query("Who",Brigade,Sex,Year1,When,Lab) :- !,

person_birthday(X,Year2),

def_when(Year1,Year2,When),

def_sex(Sex,S),

person_sex(X,S),

person_brigade(X,Brigade),

brigade_lab(Brigade,Lab),

write(X," is a ",Sex," and was born ",When," ",Year1," and consist in ",Brigade,", that has defended ",Lab,"."),nl,

fail.

% Mixed queries of any order with known variable.

composite_query(Name,Brigade,Sex,Year,When,Lab) :simple_query(Name,"",Sex,"","",""),

simple_query(Name,"","",Year,When,""),

simple_query(Name,Brigade,"","","",""),

simple_query("",Brigade,"","","",Lab).

% Simple queries to a knowledge base.

simple_query(_,"","","","","") :- !,true.

simple_query("",_,"","","","") :- !,true.

simple_query("","",_,"","","") :- !,true.

simple_query("","","","","",_) :- !,true.

% Definition of a sex.

simple_query(Name,"",Sex,"","","") :def_sex(Sex,S),

person_sex(Name,S),

write(Name," is a ",Sex,";"),nl.

simple_query(Name,"",Sex,"","","") :def_sex(Sex,S),

not(person_sex(Name,S)),

write(Name," is not a ",Sex,";"),nl.

% Definition of an accessory to a brigade.