Professional Documents
Culture Documents
Prolog
Work Done
Make
Sentence
Translation.
Sentence Translation
Main
Basic
Code
convert([H|T], L) :- drp_art([H|T], [H1|T1]), check(H1, T1, L).
convert([], []).
drp_art([], []).
drp_art([[H, a]|T], L) :- drp_art(T, L), !.
drp_art([[H, X]|T], [[H, X]|L]) :- drp_art(T, L).
check([H, a], T, L) :- convert(T, L), !.
check([H, n], T, [H|L1]) :- convert(T, L1), !.
check([H, v], T, L) :- convert(T, L1), append(L1, [H], L), !.
check([H, p], [[H1, _]|T1], L) :- convert(T1, L1), append([H1], [H], L2),
append(L2, L1, L), !.
check([H, _], T, [H|L1]) :- convert(T, L1).
Code Explained
Sample Runs
convert([[the, a], [doctor, n], [went, v], [to, p], [USA, n]], L).
L = [doctor, USA, to, went].
convert([[MI, n], [is, v], [the, a], [best, ad], [team, n], [in, p],
[the, a], [Ipl, n]], L)
L = [MI, best, team, Ipl, in, is].
Limitations
Cut Operator
Cut
Example:No
Not