c968ca0
Pinchord · pinchord.git · Tickets · Changelog
Branches > build-process > c968ca0 > files
Fix bad names in generate.clj
Commit: c968ca09207fca646092827f00b029e7e59ab8f8
Parent: 6dca7b7
1 changed file:
src/org/pinchord/generate.clj view file
@@ -3,12 +3,11 @@ [clojure.string :as str] [clojure.edn :as edn])) -(def sections [:prefixes :initials :vowels :finals :suffixes])+(def banks [:prefixes :initials :vowels :finals :suffixes]) -(def priority- "Priorities used for javelin orthospelling."- (zipmap sections- (rest (range))))+(def bank->priority+ "Map of banks to priorities used for javelin orthospelling."+ (zipmap banks (rest (range)))) (defn finalize [m] (update-keys m (partial str "-")))@@ -16,37 +15,38 @@ (defn mask [s1 s2] (apply str (remove (set s1) s2))) - (defn abbreviate- "Javelin entries can only be 6 characters long!"- [s]- (if (> (count s) 6)- (let [new-s (-> s- (str/replace #"TSPW" "G")- (str/replace #"PKS" "C")- (str/replace #"PKFS" "G")- (str/replace #"KFS" "SH")- (str/replace #"LR" "N"))]- (if (> (count new-s) 6)- (throw (ex-info "Too long!" {:s s :new-s new-s}))- new-s))- s))+(defn abbreviate+ "Abbreviates chords that are more than 6 characters,+ as Javelin entries can only be 6 characters long."+ [s]+ (if (> (count s) 6)+ (let [new-s (-> s+ (str/replace #"TSPW" "G")+ (str/replace #"PKS" "C")+ (str/replace #"PKFS" "G")+ (str/replace #"KFS" "SH")+ (str/replace #"LR" "N"))]+ (if (> (count new-s) 6)+ (throw (ex-info "Too long!" {:s s :new-s new-s}))+ new-s))+ s)) - (defn all-chords [s]- (if (empty? s)- #{""}- (let [rest-combos (all-chords (rest s))]- (set (concat- rest-combos- (map #(str (first s) %) rest-combos))))))+(defn all-chords [s]+ (if (empty? s)+ #{""}+ (let [rest-combos (all-chords (rest s))]+ (set (concat+ rest-combos+ (map #(str (first s) %) rest-combos)))))) - (defn abbreviate-long-chords [s]- (update-vals s abbreviate))+(defn abbreviate-long-chords [s]+ (update-vals s abbreviate)) - (defn with-gaps-filled [bank chords]- (let [s (remove (bank chords) (all-chords (bank (:banks chords))))]- (merge (bank chords) (abbreviate-long-chords (zipmap s s)))))+(defn with-gaps-filled [bank chords]+ (let [s (remove (bank chords) (all-chords (bank (:banks chords))))]+ (merge (bank chords) (abbreviate-long-chords (zipmap s s))))) -(defn ^:private new-value [chords]+(defn fill-gaps-in-banks [chords] (assoc chords :initials (with-gaps-filled :initials chords) :vowels (with-gaps-filled :vowels chords)@@ -54,26 +54,26 @@ (defn -main [& _args] (let [chords (-> (edn/read-string (slurp "chords.edn"))- new-value+ fill-gaps-in-banks (update :finals finalize) (update :suffixes finalize))- banks (:banks chords)+ chord-banks (:banks chords) dict {:name (str "Pinchord Base " (:version chords)) :maximumOutlineLength 1 :starters [{:stroke "#+" :definition "{^}{-|}" :mask "#+"} {:stroke "" :definition "{}" :mask ""}] :letters (->> (reduce (fn [acc [bank entries]]- (if-let [bank-keys (banks bank)]+ (if-let [bank-keys (chord-banks bank)]