<commit_before>(ns validation-benchmark.lib.spec
  (:require [clojure.spec :as s]
            [validation-benchmark.common :refer [in-range? prime?]])
  (:import [validation_benchmark.common Person]))


(s/def ::age int?)
(s/def ::name string?)
(s/def ::saiyan? (s/or :t true? :f false?))
(s/def ::keyword-set (s/every keyword :kind set?))
(s/def ::nilable-saiyan? (s/nilable ::saiyan?))
(s/def ::nilable-number (s/nilable number?))
(s/def ::nilable-string (s/nilable string?))
(s/def ::person (s/keys :req-un [::name ::saiyan? ::age]))
(s/def ::Person? #(instance? Person %))
(s/def ::range (s/tuple (partial in-range? 0.0 1.0)
                        (partial in-range? 1 10)
                        (partial in-range? 1 100)))
(s/def ::three-tuple
  (s/and coll? (s/conformer vec) (s/tuple keyword? string? number?)))
(s/def ::typed-person (s/and ::Person?
                             (s/keys :req-un [::name ::saiyan? ::age])))
(s/def ::vector-of-two-elements (s/and vector? #(= 2 (count %))))

(defn checker [s]
  (let [spec (s/spec s)]
    #(s/valid? spec %)))

(def atomic-keyword (checker keyword?))
(def atomic-number (checker number?))
(def nil-allowed-bool (checker ::nilable-saiyan?))
(def nil-allowed-number (checker ::nilable-number))
(def nil-allowed-string (checker ::nilable-string))
(def person-map (checker ::person))
(def person-record (checker ::typed-person))
(def primes (checker prime?))
(def range-check (checker ::range))
(def set-of-keywords (checker ::keyword-set))
(def three-tuple (checker ::three-tuple))
(def vector-of-two-elements (checker ::vector-of-two-elements))
(def vector-of-variable-length (checker vector?))

(defn wrapper [f valid?]
  (fn [v]
    (= (f v) valid?)))
<commit_msg>faster spec boolean validation<commit_after>(ns validation-benchmark.lib.spec
  (:require [clojure.spec :as s]
            [validation-benchmark.common :refer [in-range? prime?]])
  (:import [validation_benchmark.common Person]))


(s/def ::age int?)
(s/def ::name string?)
(s/def ::saiyan? boolean?)
(s/def ::keyword-set (s/every keyword :kind set?))
(s/def ::nilable-saiyan? (s/nilable ::saiyan?))
(s/def ::nilable-number (s/nilable number?))
(s/def ::nilable-string (s/nilable string?))
(s/def ::person (s/keys :req-un [::name ::saiyan? ::age]))
(s/def ::Person? #(instance? Person %))
(s/def ::range (s/tuple (partial in-range? 0.0 1.0)
                        (partial in-range? 1 10)
                        (partial in-range? 1 100)))
(s/def ::three-tuple
  (s/and coll? (s/conformer vec) (s/tuple keyword? string? number?)))
(s/def ::typed-person (s/and ::Person?
                             (s/keys :req-un [::name ::saiyan? ::age])))
(s/def ::vector-of-two-elements (s/and vector? #(= 2 (count %))))

(defn checker [s]
  (let [spec (s/spec s)]
    #(s/valid? spec %)))

(def atomic-keyword (checker keyword?))
(def atomic-number (checker number?))
(def nil-allowed-bool (checker ::nilable-saiyan?))
(def nil-allowed-number (checker ::nilable-number))
(def nil-allowed-string (checker ::nilable-string))
(def person-map (checker ::person))
(def person-record (checker ::typed-person))
(def primes (checker prime?))
(def range-check (checker ::range))
(def set-of-keywords (checker ::keyword-set))
(def three-tuple (checker ::three-tuple))
(def vector-of-two-elements (checker ::vector-of-two-elements))
(def vector-of-variable-length (checker vector?))

(defn wrapper [f valid?]
  (fn [v]
    (= (f v) valid?)))

{'fraction_non_alphanumeric': 0.20267131242741, 'fraction_numerical': 0.006968641114982578, 'mean_word_length': 3.7517241379310344, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1197681', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1260, 'n_words': 329}