Fix generation bug: "...a MD-50..."
This commit is contained in:
parent
516ec4bd24
commit
3c7d1c25f6
@ -68,7 +68,9 @@
|
||||
(def filters
|
||||
{:a-an (fn a-an [s]
|
||||
(if (starts-with-consonant? s)
|
||||
(str "a " s)
|
||||
(if (re-find #"^[FHLMNRSX](\b|[A-Z0-9])" s)
|
||||
(str "an " s)
|
||||
(str "a " s))
|
||||
(str "an " s)))})
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
(ns lemondronor.circlebot.generation-test
|
||||
(:require [cljs.test :refer (deftest is)]
|
||||
(:require [cljs.test :refer (deftest is testing)]
|
||||
[lemondronor.circlebot.generation :as generation]))
|
||||
|
||||
(deftest parse-template
|
||||
@ -27,7 +27,7 @@
|
||||
(generation/generate-all
|
||||
[(generation/parse-template "Hello!")]
|
||||
{})))
|
||||
(is (= "Hello!"
|
||||
(is (= "Hello!"
|
||||
(generation/generate
|
||||
[(generation/parse-template "Hello!")]
|
||||
{}))))
|
||||
@ -74,15 +74,26 @@
|
||||
|
||||
|
||||
(deftest filters
|
||||
(let [templates [(generation/parse-template "It is {thing|a-an}")]]
|
||||
(is (= "It is a bird"
|
||||
(generation/generate templates {:thing "bird"})))
|
||||
(is (= "It is an animal"
|
||||
(generation/generate templates {:thing "animal"})))
|
||||
(is (= "It is an Animal"
|
||||
(generation/generate templates {:thing "Animal"})))
|
||||
(is (= "It is a Eurocopter"
|
||||
(generation/generate templates {:thing "Eurocopter"})))))
|
||||
(testing "a-an"
|
||||
(let [templates [(generation/parse-template "It is {thing|a-an}")]]
|
||||
(is (= "It is a bird"
|
||||
(generation/generate templates {:thing "bird"})))
|
||||
(is (= "It is an animal"
|
||||
(generation/generate templates {:thing "animal"})))
|
||||
(is (= "It is an Animal"
|
||||
(generation/generate templates {:thing "Animal"})))
|
||||
(is (= "It is a Eurocopter"
|
||||
(generation/generate templates {:thing "Eurocopter"})))
|
||||
(is (= "It is an MD-500"
|
||||
(generation/generate templates {:thing "MD-500"})))
|
||||
(is (= "It is an F-15"
|
||||
(generation/generate templates {:thing "F-15"})))
|
||||
(is (= "It is an X-15"
|
||||
(generation/generate templates {:thing "X-15"})))
|
||||
(is (= "It is a KXL-10"
|
||||
(generation/generate templates {:thing "KXL-10"})))
|
||||
|
||||
)))
|
||||
|
||||
;; (deftest var-paths
|
||||
;; (is (= "Hello, John"
|
||||
|
Loading…
Reference in New Issue
Block a user