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

Added examples for testing purposes

parent 3a155991
......@@ -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.
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
(dl/->pipeline {:annotators ["truecase"
"quote"
......@@ -17,6 +23,7 @@
"parse"
"depparse"
"lemma"
"relation"
"coref"
"openie"
"ner"]
......@@ -28,7 +35,19 @@
(def sentences
(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)))
......@@ -37,18 +56,35 @@
(map dl/true-case @sentences)
(map dl/quotations @sentences)
(map dl/mentions @sentences)
(map dl/annotation "relation" @sentences)
(map dl/constituency-tree @sentences)
(map dl/dependency-graph @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))
(dl/annotation CorefCoreAnnotations$CorefChainAnnotation @annotated-example)
(show-sentences)
(show-mentions)
;; Datafy the annotations. Retrieves direct annotations for every sentence.
;; Keep in mind that `dl/recur-datafy` currently doesn't work in this instance
;; and will possibly be removed in a future update:
;; 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 @@
(let [shutdown-trigger (promise)
_bye-testing-hack (future (Thread/sleep 6000) (deliver shutdown-trigger true))]
(log/info "Dialect Detector started up.")
(nlp/show-sentences)
(nlp/show-mentions)
@shutdown-trigger
(log/info "Dialect Detector shutting down..."))
(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