Created
July 15, 2011 16:56
-
-
Save swannodette/1085065 to your computer and use it in GitHub Desktop.
dcg.clj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def-->e verb [v] | |
([[:v 'eats]] '[eats])) | |
(def-->e noun [n] | |
([[:n 'bat]] '[bat]) | |
([[:n 'cat]] '[cat])) | |
(def-->e det [d] | |
([[:d 'the]] '[the]) | |
([[:d 'a]] '[a])) | |
(def-->e noun-phrase [n] | |
([[:np ?d ?n]] (det ?d) (noun ?n))) | |
(def-->e verb-phrase [n] | |
([[:vp ?v ?np]] (verb ?v) (noun-phrase ?np))) | |
(def-->e sentence [s] | |
([[:s ?np ?vp]] (noun-phrase ?np) (verb-phrase ?vp))) | |
(run 1 [parse-tree] | |
(sentence parse-tree '[the bat eats a cat] [])) | |
;; ([:s [:np [:d the] [:n bat]] [:vp [:v eats] [:np [:d a] [:n cat]]]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment