English sinfi
Prologda English sinfini yasab olganimizdan keyin English Pro paketiga dasturimizni kiritamiz. Bu dasturni ko’rinishi quyidagicha:
% Fayl english.pro
implement english
open core, semantic
clauses
%% classInfo("english", "1.0").
article(case(art, ""), ["the"]).
noun(case(nom, "Welt"), ["world"]).
noun(case(nom, "Fall"), ["case"]).
noun(case(nom, "alles"), ["all"]).
nounphr( world(T1, T2), list::append(A,N)) :-
article(T1, A), noun(T2, N).
nounphr( case(nom, "alles"), ["all"]).
copula(world(case(cop, "ist"), T), list::append(["is"], R1)) :-
nounphr(T, R1).
phr(world(T1, T2), list::append(Start, S1)) :-
nounphr(T1, Start), copula(T2, S1).
end implement English
Xuddi avvalgi bo’limda German sinfida gapirib o’tganimizdagidek English sinfiga ham keyingi dasturimizni kiritamiz. Bu dastur quyidagicha:
% Fayl english.cl
class english
open core, semantic
predicates
classInfo : core::classInfo.
article : (tree, string*) nondeterm (i,o)(o,o).
noun : (tree, string*) nondeterm (i,o)(o,o).
nounphr : (tree, string*) nondeterm (i,o)(o,o).
copula : (tree, string*) nondeterm (o,o)(i, o).
phr : (tree, string*) nondeterm (i,o).
end class english
Shu bilan English sinfiga ham dasturlarni kiritib bo’ldik. Endi esa bu dasturlarni ishlatib ko’ramiz. Bu uchun Prolog dasturida masalalar paneliga borib, Build tugmasini ustiga borib bosamiz. So’ngra shu oynadan Build tugmasini bosamiz. Bizni ekranimida quyidagicha oyna hosil bo’ladi. Bu oynadan Cancel tugmasini bosamiz. Bizni dasturlarimizda xatolik bo’lmasa xato chiqarmaydi.
|