<commit_before>;;;;; tré – Copyright (c) 2007-2009,2011–2012 <NAME> <<EMAIL>>

(def-head-predicate %exec)

(defun lml-attr? (x)
  (& (cons? x) (cons? .x)
     (atom x.)
     (keyword? x.)
     (| (atom .x.)
	    (%exec? .x.))))

(defun lml-body (x)
  (& x (? (lml-attr? x)
	      (lml-body ..x)
	      x)))

(defun lml2xml-end (s)
  (princ ">" s))

(defun lml2xml-end-inline (s)
  (princ "/>" s))

(defun lml2xml-open (s x)
  (princ (string-concat "<" (lml-attr-string x.)) s))

(defun lml2xml-close (s x)
  (princ (string-concat "</" (lml-attr-string x.) ">") s))

(defun lml2xml-atom (s x)
  (princ x s))

(defun lml2xml-attr (s x)
  (princ (string-concat " "
			            (lml-attr-string x.)
                        "=\""
			            (? (string? .x.)
                           .x.
				           (lml-attr-string .x.))
                        "\"")
         s)
  (lml2xml-attr-or-body s ..x))

(defun lml2xml-body (s x)
  (lml2xml-end s)
  (mapcar (fn lml2xml-0 s _) x))

(defun lml2xml-attr-or-body (s x)
  (when x
    (? (lml-attr? x)
       (lml2xml-attr s x)
       (lml2xml-body s x))))

(defun lml2xml-block (s x)
  (lml2xml-attr-or-body s .x)
  (lml2xml-close s x))

(defun lml2xml-inline (s x)
  (lml2xml-attr-or-body s .x)
  (lml2xml-end-inline s))

(defun lml2xml-error-tagname (x)
  (error "First element is not a tag name: ~A" x))

(defun lml2xml-expr (s x)
  (unless (atom x.)
    (lml2xml-error-tagname x))
  (lml2xml-open s x)
  (? (lml-body .x)
     (lml2xml-block s x)
     (lml2xml-inline s x)))

(defun lml2xml-0 (s x)
  (when x
    (? (cons? x)
	   (lml2xml-expr s x)
	   (lml2xml-atom s x))))

(defun lml2xml (x &optional (str nil))
  (with-default-stream s str
	(lml2xml-0 s x)))<commit_msg>Cleanup. Use loop instead of MAPCAR.<commit_after>;;;;; tré – Copyright (c) 2007-2009,2011–2012 <NAME> <<EMAIL>>

(def-head-predicate %exec)

(defun lml-attr? (x)
  (& (cons? x) (cons? .x)
     (atom x.)
     (keyword? x.)
     (| (atom .x.)
	    (%exec? .x.))))

(defun lml-body (x)
  (& x (? (lml-attr? x)
	      (lml-body ..x)
	      x)))

(defun lml2xml-end (s)
  (princ ">" s))

(defun lml2xml-end-inline (s)
  (princ "/>" s))

(defun lml2xml-open (s x)
  (princ (string-concat "<" (lml-attr-string x.)) s))

(defun lml2xml-close (s x)
  (princ (string-concat "</" (lml-attr-string x.) ">") s))

(defun lml2xml-atom (s x)
  (princ x s))

(defun lml2xml-attr (s x)
  (princ (string-concat " "
                        (lml-attr-string x.)
                        "=\""
		                (? (string? .x.)
                           .x.
                           (lml-attr-string .x.))
                        "\"")
             s)
  (lml2xml-attr-or-body s ..x))

(defun lml2xml-body (s x)
  (lml2xml-end s)
  (dolist (i x)
    (lml2xml-0 s i)))

(defun lml2xml-attr-or-body (s x)
  (& x
     (? (lml-attr? x)
        (lml2xml-attr s x)
        (lml2xml-body s x))))

(defun lml2xml-block (s x)
  (lml2xml-attr-or-body s .x)
  (lml2xml-close s x))

(defun lml2xml-inline (s x)
  (lml2xml-attr-or-body s .x)
  (lml2xml-end-inline s))

(defun lml2xml-error-tagname (x)
  (error "First element is not a tag name symbol but ~A" x))

(defun lml2xml-expr (s x)
  (| (atom x.)
     (lml2xml-error-tagname x))
  (lml2xml-open s x)
  (? (lml-body .x)
     (lml2xml-block s x)
     (lml2xml-inline s x)))

(defun lml2xml-0 (s x)
  (& x
     (? (cons? x)
	    (lml2xml-expr s x)
	    (lml2xml-atom s x))))

(defun lml2xml (x &optional (str nil))
  (with-default-stream s str
	(lml2xml-0 s x)))
{'fraction_non_alphanumeric': 0.1944127708095781, 'fraction_numerical': 0.027936145952109463, 'mean_word_length': 1.9712108382726503, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 60}, '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': '2857402', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1577, 'n_words': 382}