<commit_before>;   Copyright (c) <NAME>. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;   which can be found in the file epl-v10.html at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.

(ns clojure.data.xml.event
  "Data type for xml pull events"
  {:author "<NAME>"}
  (:require [clojure.data.xml.protocols :refer
             [EventGeneration gen-event next-events]]
            [clojure.data.xml.name :refer [merge-nss separate-xmlns]]
            [clojure.data.xml.node :refer [element* cdata xml-comment]]
            [clojure.data.xml.impl :refer [extend-protocol-fns]])
  (:import (clojure.data.xml.node Element CData Comment)))

(definline element-nss* [element]
  (get (meta element) :clojure.data.xml/nss {}))

(defn element-nss
  "Get xmlns environment from element"
  [{:keys [attrs] :as element}]
  (separate-xmlns
   attrs #(merge-nss (element-nss* element) %2)))

; Represents a parse event.
; type is one of :start-element, :end-element, or :characters
(defrecord StartElementEvent [tag attrs nss])
(defrecord EndElementEvent [tag])
(defrecord CharsEvent [str])
(defrecord CDataEvent [str])
(defrecord CommentEvent [str])

;; Event Generation for stuff to show up in generated xml

(let [second-arg #(do %2)
      elem-event-generation
      {:gen-event (fn elem-gen-event [{:keys [tag attrs] :as element}]
                    (separate-xmlns
                     attrs #(->StartElementEvent
                             tag %1 (merge-nss (element-nss* element) %2))))<commit_msg>Fix element-nss<commit_after>;   Copyright (c) <NAME>. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;   which can be found in the file epl-v10.html at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.

(ns clojure.data.xml.event
  "Data type for xml pull events"
  {:author "<NAME>"}
  (:require [clojure.data.xml.protocols :refer
             [EventGeneration gen-event next-events]]
            [clojure.data.xml.name :refer [merge-nss separate-xmlns]]
            [clojure.data.xml.node :refer [element* cdata xml-comment]]
            [clojure.data.xml.impl :refer [extend-protocol-fns]])
  (:import (clojure.data.xml.node Element CData Comment)))

(definline element-nss* [element]
  `(get (meta ~element) :clojure.data.xml/nss {}))

(defn element-nss
  "Get xmlns environment from element"
  [{:keys [attrs] :as element}]
  (separate-xmlns
   attrs #(merge-nss (element-nss* element) %2)))

; Represents a parse event.
; type is one of :start-element, :end-element, or :characters
(defrecord StartElementEvent [tag attrs nss])
(defrecord EndElementEvent [tag])
(defrecord CharsEvent [str])
(defrecord CDataEvent [str])
(defrecord CommentEvent [str])

;; Event Generation for stuff to show up in generated xml

(let [second-arg #(do %2)
      elem-event-generation
      {:gen-event (fn elem-gen-event [{:keys [tag attrs] :as element}]
                    (separate-xmlns
                     attrs #(->StartElementEvent
                             tag %1 (merge-nss (element-nss* element) %2))))
{'fraction_non_alphanumeric': 0.12122060470324748, 'fraction_numerical': 0.005599104143337066, 'mean_word_length': 3.159487776484284, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1680177', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1124, 'n_words': 374}