Fix generation bug: "...a MD-50..."
This commit is contained in:
parent
516ec4bd24
commit
3c7d1c25f6
@ -68,7 +68,9 @@
|
|||||||
(def filters
|
(def filters
|
||||||
{:a-an (fn a-an [s]
|
{:a-an (fn a-an [s]
|
||||||
(if (starts-with-consonant? 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)))})
|
(str "an " s)))})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(ns lemondronor.circlebot.generation-test
|
(ns lemondronor.circlebot.generation-test
|
||||||
(:require [cljs.test :refer (deftest is)]
|
(:require [cljs.test :refer (deftest is testing)]
|
||||||
[lemondronor.circlebot.generation :as generation]))
|
[lemondronor.circlebot.generation :as generation]))
|
||||||
|
|
||||||
(deftest parse-template
|
(deftest parse-template
|
||||||
@ -74,6 +74,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(deftest filters
|
(deftest filters
|
||||||
|
(testing "a-an"
|
||||||
(let [templates [(generation/parse-template "It is {thing|a-an}")]]
|
(let [templates [(generation/parse-template "It is {thing|a-an}")]]
|
||||||
(is (= "It is a bird"
|
(is (= "It is a bird"
|
||||||
(generation/generate templates {:thing "bird"})))
|
(generation/generate templates {:thing "bird"})))
|
||||||
@ -82,7 +83,17 @@
|
|||||||
(is (= "It is an Animal"
|
(is (= "It is an Animal"
|
||||||
(generation/generate templates {:thing "Animal"})))
|
(generation/generate templates {:thing "Animal"})))
|
||||||
(is (= "It is a Eurocopter"
|
(is (= "It is a Eurocopter"
|
||||||
(generation/generate templates {:thing "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
|
;; (deftest var-paths
|
||||||
;; (is (= "Hello, John"
|
;; (is (= "Hello, John"
|
||||||
|
Loading…
Reference in New Issue
Block a user