Commit 836ca08d authored by Jonathan Poalses's avatar Jonathan Poalses

Added examples of different usages of the word "like".

parent 1d77987c
......@@ -19,6 +19,15 @@
(def test-sentence-three
"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 test-sentence-four
"This is an example of incorrect language usage. I had an idea about using garlic butter with chicken, hence why the food was burnt. This one has an extra sentence to tip the balance to good.")
(def test-sentence-five
"This is an example of Californian slang. So, like, I had this great idea, where we put like, garlic butter with chicken, it's so rad.")
(def test-sentence-six
"This is all about like. I like lychees, they're delicious. Sometimes life is like watching paint dry, basically very boring")
(def nlp
(dl/->pipeline {:annotators ["truecase"
"quote"
......@@ -42,10 +51,7 @@
;; Take a text sample and separate it into it's sentences, then for each sentence find its dialect, and return the most common dialect
(defn detect-sample-dialect [sample]
(first (last (sort-by val (frequencies (map detect-sentence-dialect sample))))))
(first (last (sort-by val (frequencies (map detect-sentence-dialect (dl/sentences (nlp sample))))))))
(def annotated-example
(delay (nlp example)))
......@@ -65,11 +71,29 @@
(def sentences-three
(dl/sentences @annotated-example-three))
(def annotated-example-four
(delay (nlp test-sentence-four)))
(def sentences-four
(dl/sentences @annotated-example-four))
(def annotated-example-five
(delay (nlp test-sentence-five)))
(def sentences-five
(dl/sentences @annotated-example-five))
(def annotated-example-six
(delay (nlp test-sentence-six)))
(def sentences-six
(dl/sentences @annotated-example-six))
(def annotated-example-two
(delay (nlp test-sentence-two)))
(def sentences-two
(delay (dl/sentences @annotated-example-two)))
(dl/sentences @annotated-example-two))
(defn show-dependencies []
(clojure.pprint/pprint (dl/dependency-graph (nth sentences-one 1))))
......@@ -102,6 +126,49 @@
(def rats (datafy (dl/dependency-graph (nth sentences-one 1))))
(last (vals rats))
(.getTarget (first (last (vals rats))))
(bean (first (last (vals rats))))
(bean (:relation (bean (first (last (vals rats))))))
(datafy (dl/dependency-graph (nth sentences-one 1)))
(datafy (dl/dependency-graph (nth sentences-five 1)))
(datafy (dl/dependency-graph (nth sentences-six 0)))
(datafy (dl/dependency-graph (nth sentences-six 1)))
(datafy (dl/dependency-graph (nth sentences-six 2)))
(bean (:relation (bean (nth (nth (vals (datafy (dl/dependency-graph (nth sentences-five 1)))) 3) 2))))
(.tag (:target (bean (nth (nth (vals (datafy (dl/dependency-graph (nth sentences-five 1)))) 3) 2))))
(.word (:target (bean (nth (nth (vals (datafy (dl/dependency-graph (nth sentences-five 1)))) 3) 2))))
(.word (nth (keys (datafy (dl/dependency-graph (nth sentences-one 1)))) 9))
(.after (nth (keys (datafy (dl/dependency-graph (nth sentences-one 1)))) 9))
(.word (nth (keys (datafy (dl/dependency-graph (nth sentences-one 1)))) 10))
(.word (nth (keys (datafy (dl/dependency-graph (nth sentences-one 1)))) 7))
(.after (nth (keys (datafy (dl/dependency-graph (nth sentences-one 1)))) 7))
(.word (nth (keys (datafy (dl/dependency-graph (nth sentences-two 1)))) 9))
(.after (nth (keys (datafy (dl/dependency-graph (nth sentences-two 1)))) 9))
(.word (nth (keys (datafy (dl/dependency-graph (nth sentences-two 1)))) 10))
(.tag (nth (keys (datafy (dl/dependency-graph (nth sentences-two 1)))) 10))
(.tag (nth (keys (datafy (dl/dependency-graph (nth sentences-two 1)))) 9))
(.tag (nth (keys (datafy (dl/dependency-graph (nth sentences-two 1)))) 10))
(.tag (nth (keys (datafy (dl/dependency-graph (nth sentences-two 1)))) 9))
;; So two main ways, word use and grammar. Word use is simple enough,
;;just check if a word in the sentence matches the expected word
;; For example, this returns true if the word "why" is in the given sentence
(some #(= "why" %) (dl/text (dl/tokens sentence)))
;; Then we have grammar, which is a lot harder to check. For instance, a sentence using "like"
;;as an interjection should return true when passed to the following code.
(some #(when (even? %) %) '(1 2 3 4))
(def something [5647 5858 76 938 62626])
(reduce + something)
......@@ -122,7 +189,13 @@
(detect-sample-dialect sentences-one)
(detect-sample-dialect @sentences-two)
(detect-sample-dialect sentences-three)
(detect-sample-dialect sentences-four)
(detect-sample-dialect test-sentence-one)
(detect-sample-dialect test-sentence-two)
(detect-sample-dialect test-sentence-three)
(detect-sample-dialect test-sentence-four)
(first (last (sort-by val (frequencies (map detect-sentence-dialect sentences-one)))))
(first (last (sort-by val (frequencies (map detect-sentence-dialect @sentences-two)))))
......
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