Skip to content

Instantly share code, notes, and snippets.

@PythonJedi
Created September 23, 2016 17:07
Show Gist options
  • Save PythonJedi/b0e51c64154c36e5f8c268e0b1b7ce5d to your computer and use it in GitHub Desktop.
Save PythonJedi/b0e51c64154c36e5f8c268e0b1b7ce5d to your computer and use it in GitHub Desktop.
noun(man).
noun(ball).
verb(hit).
verb(took).
article(the).
% Handle splitting sublists
is_cat([], B, C) :-
B = C.
is_cat([A|AS], BS, [C|CS]) :-
A = C,
is_cat(AS, BS, CS).
verb_phrase(A) :-
[X|Y] = A,
verb(X),
noun_phrase(Y).
noun_phrase(A) :-
[X, Y] = A,
article(X),
noun(Y).
sentence(A) :-
is_cat(X, Y, A),
noun_phrase(X),
verb_phrase(Y).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment