<commit_before>(ns whitman.config
  (:require [clojure.data.json :as json]
            [whitman.utils :as utils]))

(def ^:private default-user-agent
  (str "whitman/" utils/version))

(defn ^:private user-agent [cfg]
  (if (contains? cfg "user-agent")
    (format (get cfg "user-agent") utils/version)
    default-user-agent))

(defn ^:private format-config [cfg]
  (assoc cfg "user-agent" (user-agent cfg)))

(defn file-extension [path]
  (let [dot (.lastIndexOf path ".")]
    (if (> dot 0)
      (.substring path (+ dot 1))
      "")))

(defn file-format [path]
  (case (file-extension path)
        "ini"  :ini
        "json" :json
        "yaml" :yml
        "yml"  :yml
        nil))

(defmulti read-config file-format)
(defmethod read-config :json [path]
  (-> path slurp json/read-str format-config))
<commit_msg>Better formatting of cond statement<commit_after>(ns whitman.config
  (:require [clojure.data.json :as json]
            [whitman.utils :as utils]))

(def ^:private default-user-agent
  (str "whitman/" utils/version))

(defn ^:private user-agent [cfg]
  (if (contains? cfg "user-agent")
    (format (get cfg "user-agent") utils/version)
    default-user-agent))

(defn ^:private format-config [cfg]
  (assoc cfg "user-agent" (user-agent cfg)))

(defn file-extension [path]
  (let [dot (.lastIndexOf path ".")]
    (if (> dot 0)
      (.substring path (+ dot 1))
      "")))

(defn file-format [path]
  (case (file-extension path)
    "ini"  :ini
    "json" :json
    "yaml" :yml
    "yml"  :yml
    nil))

(defmulti read-config file-format)
(defmethod read-config :json [path]
  (-> path slurp json/read-str format-config))

{'fraction_non_alphanumeric': 0.16646415552855406, 'fraction_numerical': 0.002430133657351154, 'mean_word_length': 3.0466830466830466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3674039', 'n_tokens_mistral': 611, 'n_tokens_neox': 590, 'n_words': 160}