-
Notifications
You must be signed in to change notification settings - Fork 2
/
stopword_test.clj
37 lines (33 loc) · 1.41 KB
/
stopword_test.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(ns zensols.nlparse.stopword-test
(:require [clojure.test :refer :all]
[clojure.string :as s]
[zensols.nlparse.stopword :refer :all]
[zensols.nlparse.parse :as p]
[zensols.nlparse.config :as conf :refer (with-context)]))
(defonce ^:private context
(->> (conf/create-parse-config
:pipeline [(conf/tokenize)
(conf/sentence)
(conf/part-of-speech)
(conf/morphology)
(conf/stopword)])
conf/create-context))
;(ns-unmap *ns* 'context)
(defn- parse [utterance]
(with-context context
(p/parse utterance)))
(deftest go-tokens-test []
(testing "Filter semantically significant words"
(is (= ["test" "filter" "semantically" "significant" "words"]
(->> (parse "This is a test. This will filter 5 semantically significant words.")
p/tokens
go-word-forms)))))
(deftest go-tokens-config-test []
(testing "Filter semantically significant word via config changes"
(binding [*stopword-config* (assoc *stopword-config*
:pos-tags (p/pos-tags 'noun)
:word-form-fn #(-> % :lemma s/lower-case))]
(is (= ["test" "word"]
(->> (parse "This is a test. This cleans 5 semantically significant words.")
p/tokens
go-word-forms))))))