<commit_before>(ns seria.util.coll
  "Generic collection utils."
  (:require [clojure.set :as set]))

(defn id-map [coll]
  (->> coll
       (map-indexed #(vector %2 %1))
       (into {})))

(defn bimap [coll]
  (->> coll
       (distinct)
       (map-indexed vector)
       (into {})
       ((juxt set/map-invert identity))))

(defn find-by [f form]
  (cond-> []
    (f form)
    (conj form)

    (or (sequential? form)
        (map? form))
    (concat (mapcat (partial find-by f) form))))

(defn find-unique-by [f form]
  (distinct (find-by f form)))
<commit_msg>Remove unnecessary bimap fn<commit_after>(ns seria.util.coll
  "Generic collection utils."
  (:require [clojure.set :as set]))

(defn id-map [coll]
  (->> coll
       (map-indexed #(vector %2 %1))
       (into {})))

(defn find-by [f form]
  (cond-> []
    (f form)
    (conj form)

    (or (sequential? form)
        (map? form))
    (concat (mapcat (partial find-by f) form))))

(defn find-unique-by [f form]
  (distinct (find-by f form)))

{'fraction_non_alphanumeric': 0.182720953326713, 'fraction_numerical': 0.003972194637537239, 'mean_word_length': 2.6, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6584080', 'n_tokens_mistral': 390, 'n_tokens_neox': 386, 'n_words': 106}