Commit 5e517ecf authored by Jonathan Poalses's avatar Jonathan Poalses

Added examples for testing purposes

parent 3a155991
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
Having had no previous experience with NLP libraries, I was wondering why I couldn’t get your examples to work. Then I realized that I had to download CoreNLP first from https://stanfordnlp.github.io/CoreNLP/ and add stanford-corenlp-4.4.0/* to the classpath. Everything worked fine after that. Having had no previous experience with NLP libraries, I was wondering why I couldn’t get your examples to work. Then I realized that I had to download CoreNLP first from https://stanfordnlp.github.io/CoreNLP/ and add stanford-corenlp-4.4.0/* to the classpath. Everything worked fine after that.
Is this what you are supposed to do? It wasn’t mentioned in the readme, so I was wondering if I did something wrong here or if it is more obvious to people who have already worked with CoreNLP.") Is this what you are supposed to do? It wasn’t mentioned in the readme, so I was wondering if I did something wrong here or if it is more obvious to people who have already worked with CoreNLP.")
(def test-sentence-one
"This is an example of correct language usage. I had an idea about using garlic butter with chicken, hence the food was burnt.")
(def test-sentence-two
"This is an example of incorrect language usage. I had an idea about using garlic butter with chicken, hence why the food was burnt.")
(def nlp (def nlp
(dl/->pipeline {:annotators ["truecase" (dl/->pipeline {:annotators ["truecase"
"quote" "quote"
...@@ -17,6 +23,7 @@ ...@@ -17,6 +23,7 @@
"parse" "parse"
"depparse" "depparse"
"lemma" "lemma"
"relation"
"coref" "coref"
"openie" "openie"
"ner"] "ner"]
...@@ -28,7 +35,19 @@ ...@@ -28,7 +35,19 @@
(def sentences (def sentences
(delay (dl/sentences @annotated-example))) (delay (dl/sentences @annotated-example)))
(defn show-sentences [] (def annotated-example-one
(delay (nlp test-sentence-one)))
(def sentences-one
(delay (dl/sentences @annotated-example-one)))
(def annotated-example-two
(delay (nlp test-sentence-two)))
(def sentences-two
(delay (dl/sentences @annotated-example-two)))
(defn show-mentions []
(clojure.pprint/pprint (map dl/mentions @sentences))) (clojure.pprint/pprint (map dl/mentions @sentences)))
...@@ -37,18 +56,35 @@ ...@@ -37,18 +56,35 @@
(map dl/true-case @sentences) (map dl/true-case @sentences)
(map dl/quotations @sentences) (map dl/quotations @sentences)
(map dl/mentions @sentences) (map dl/mentions @sentences)
(map dl/annotation "relation" @sentences)
(map dl/constituency-tree @sentences) (map dl/constituency-tree @sentences)
(map dl/dependency-graph @sentences) (map dl/dependency-graph @sentences)
(map dl/lemma @sentences) (map dl/lemma @sentences)
(map dl/mentions @sentences) (map dl/lemma @sentences-one)
(map dl/lemma @sentences-two)
(->> (mapcat dl/triples @sentences) (map triple->datalog)) (->> (mapcat dl/triples @sentences) (map triple->datalog))
(dl/annotation CorefCoreAnnotations$CorefChainAnnotation @annotated-example) (dl/annotation CorefCoreAnnotations$CorefChainAnnotation @annotated-example)
(show-sentences) (show-mentions)
;; Datafy the annotations. Retrieves direct annotations for every sentence. ;; Datafy the annotations. Retrieves direct annotations for every sentence.
;; Keep in mind that `dl/recur-datafy` currently doesn't work in this instance ;; Keep in mind that `dl/recur-datafy` currently doesn't work in this instance
;; and will possibly be removed in a future update: ;; and will possibly be removed in a future update:
;; https://github.com/simongray/datalinguist/issues/13 ;; https://github.com/simongray/datalinguist/issues/13
(map datafy @sentences) (into {} (map datafy @sentences))
(keys (into {} (map datafy @sentences)))
(:natural-logic/relation-triples (into {} (map datafy @sentences)))
(:semantic-graph/enhanced-plus-plus-dependencies (into {} (map datafy @sentences)))
(:semantic-graph/collapsed-dependencies (into {} (map datafy @sentences)))
(:coref/mentions (into {} (map datafy @sentences)))
(:tokens (into {} (map datafy @sentences)))
(def play-map (into {} (map datafy @sentences)))
(def play-map (into {} (datafy @annotated-example)))
sentences
@sentences
play-map
(:text play-map)
#_.) #_.)
\ No newline at end of file
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
(let [shutdown-trigger (promise) (let [shutdown-trigger (promise)
_bye-testing-hack (future (Thread/sleep 6000) (deliver shutdown-trigger true))] _bye-testing-hack (future (Thread/sleep 6000) (deliver shutdown-trigger true))]
(log/info "Dialect Detector started up.") (log/info "Dialect Detector started up.")
(nlp/show-sentences) (nlp/show-mentions)
@shutdown-trigger @shutdown-trigger
(log/info "Dialect Detector shutting down...")) (log/info "Dialect Detector shutting down..."))
(catch Exception e (catch Exception e
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment