Created
December 17, 2012 23:23
-
-
Save jirkamarsik/4323409 to your computer and use it in GitHub Desktop.
Tree-rewriting rules using unification.
This file contains 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
(defn simple-rule [in-tree] | |
(if-let [res (seq (run 1 [out-tree] | |
(fresh [X Y Z W] | |
(== in-tree ['VP X Y ['PP Z W]]) | |
(== out-tree ['VP ['VP X Y] ['PP Z W]]))))] | |
(first res) | |
in-tree)) | |
;=> #'user/simple-rule | |
(simple-rule '[VP [VB plays] [NP piano] [PP [IN for] [NP fun]]]) | |
;=> [VP [VP [VB plays] [NP piano]] [PP [IN for] [NP fun]]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment