(ns advent.analyze (:require [slam.hound.asplode :as a] [clojure.java.io :as io] [clojure.pprint :as pprint] [clojure.data.csv :as csv] )) (defn get-speech [f] (->> f (io/file) a/asplode second (tree-seq coll? seq) (filter (fn [form] (and (seq? form) (#{"talk" "respond" "actions/respond" "actions/talk" "actions/do-dialogue"} (str (first form)))))) (map (fn [call] (cond (= "actions/respond" (str (first call))) (drop 3 call) (= "talk" (str (first call))) [:ego (second call)] (= "respond" (str (first call))) [:frankie (second call)] :else (drop 2 call) ))) (reduce concat) (partition 2 ) (filter (comp (complement #{:anim :stop :stop? :animate?} ) first)) (map #(vector (name (first %)) (second %))) )) (defn dump-speech [] (with-open [out-file (io/writer "target/script.csv")] (csv/write-csv out-file (->> (file-seq (io/file "src-common")) (map #(.getPath %) ) (filter #(.endsWith % ".clj") ) (mapcat get-speech )))))