<commit_before>(ns datomic-dsl.add-nested
  (:require
   [datomic.api :as d]
   [clojure.zip :as zip]
   [datomic-dsl.created-nested :refer [map-zip dsl-zipper zip-nodes]]))


<commit_msg>add some helper functions<commit_after>(ns datomic-dsl.add-nested
  (:require
   [datomic.api :as d]
   [clojure.zip :as zip]
   [datomic-dsl.created-nested :refer [map-zip dsl-zipper zip-nodes]]))

(defn up-stepper
  "Step over the map-entries up."
  [node]
  (take-while (complement nil)
              (iterate zip/up node)))

(defn zip-nde-map-entries
  "If this is a map-entry - get the key out of the zipper."
  [me]
  (if (= (type (zip/node me)) clojure.lang.MapEntry)
    (key (zip/node ma))))

(defn steps-up
  "Keys to the top for a given node."
  [node]
  (filter (comp not all?)
          (map zip-node-map-entries
               (up-zipper node))))

(defn map-key-seqs
  "For a given dsl, get a sequence of steps to each of the nested nodes."
  [dsl]
  (filter
   (comp not empty?)
   (map step-up
        (zip-nodes
         dsl-zipper dsl))))


{'fraction_non_alphanumeric': 0.14244741873804972, 'fraction_numerical': 0.0, 'mean_word_length': 2.6736842105263157, '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': '1999950', 'n_tokens_mistral': 399, 'n_tokens_neox': 395, 'n_words': 114}