Skip to content

Instantly share code, notes, and snippets.

@JonyEpsilon
Last active November 13, 2015 02:58
Show Gist options
  • Save JonyEpsilon/5baef8ac0f42706e4940 to your computer and use it in GitHub Desktop.
Save JonyEpsilon/5baef8ac0f42706e4940 to your computer and use it in GitHub Desktop.
Using the Stanford NLP LexicalizedParser in clojure
;; gorilla-repl.fileformat = 1
;; **
;;; # Loading a lexparser
;; **
;; @@
(ns fuscia-sunset
(:import (edu.stanford.nlp.parser.lexparser LexicalizedParser Options)))
;; @@
;; =>
;;; {"type":"html","content":"<span class='clj-nil'>nil</span>","value":"nil"}
;; <=
;; @@
(def parser
(LexicalizedParser/loadModelFromZip
"stanford-parser-3.4.1-models.jar"
"edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz"))
;; @@
;; =>
;;; {"type":"html","content":"<span class='clj-var'>#&#x27;fuscia-sunset/parser</span>","value":"#'fuscia-sunset/parser"}
;; <=
;; @@
(.parse parser "Hello, world!")
;; @@
;; =>
;;; {"type":"html","content":"<span class='clj-unkown'>#&lt;LabeledScoredTreeNode (ROOT (FRAG (INTJ (UH Hello)) (, ,) (NP (NN world)) (. !)))&gt;</span>","value":"#<LabeledScoredTreeNode (ROOT (FRAG (INTJ (UH Hello)) (, ,) (NP (NN world)) (. !)))>"}
;; <=
;; @@
;; @@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment