<commit_before>;;;;; phitamine – Copyright (c) 2012 <NAME> <<EMAIL>>

(defvar *template-parameters* nil)
(defvar *currently-processed-templates* nil)

(defun template-param-value (name &key (if-exists? nil))
  (!? (assoc name *template-parameters* :test #'eq)
      .!
      (unless if-exists?
        (princ "<br>Current template parameters:<br>")
        (print *template-parameters*)
        (princ "<br>")
        (error "template parameter ~A not found" (symbol-name name)))))

(defun template-param (name &key (if-exists? nil))
  (force-list (template-param-value name :if-exists? if-exists?)))

(defmacro define-template (name &key path)
  (print-definition `(define-template ,name :path ,path))
  `(defun ,name (&optional (params nil))
     (& (member ',name *currently-processed-templates*)
        (error "template ~A called recursively" ',name))
     (with-temporaries (*template-parameters* (append params *template-parameters*)
                        *currently-processed-templates* (cons ',name *currently-processed-templates*))
       (apply #'string-concat (filter #'lml2xml ,(list 'backquote (dot-expand (read-file-all path))))))))

(defun template-list (template records)
  (let index 0
    (apply #'string-concat (filter [with-temporary *template-parameters* (cons (cons 'index (1+! index)) *template-parameters*)
                                     (funcall template _)]
                                   records))))<commit_msg>TEMPLATE-PARAM: Removed.<commit_after>;;;;; phitamine – Copyright (c) 2012 <NAME> <<EMAIL>>

(defvar *template-parameters* nil)
(defvar *currently-processed-templates* nil)

(defun param (name &key (if-exists? nil))
  (!? (assoc name *template-parameters* :test #'eq)
      .!
      (unless if-exists?
        (princ "<br>Current template parameters:<br>")
        (print *template-parameters*)
        (princ "<br>")
        (error "template parameter ~A not found" (symbol-name name)))))

(defmacro define-template (name &key path)
  (print-definition `(define-template ,name :path ,path))
  `(defun ,name (&optional (params nil))
     (& (member ',name *currently-processed-templates*)
        (error "template ~A called recursively" ',name))
     (with-temporaries (*template-parameters* (append params *template-parameters*)
                        *currently-processed-templates* (cons ',name *currently-processed-templates*))
       (apply #'string-concat (filter #'lml2xml ,(list 'backquote (dot-expand (read-file-all path))))))))

(defun template-list (template records)
  (when records
    (let index 0
      (apply #'string-concat (filter [with-temporary *template-parameters* (cons (cons 'index (1+! index)) *template-parameters*)
                                       (funcall template _)]
                                     records)))))
{'fraction_non_alphanumeric': 0.1565620542082739, 'fraction_numerical': 0.004992867332382311, 'mean_word_length': 3.1310751104565537, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1012816', 'n_tokens_mistral': 842, 'n_tokens_neox': 805, 'n_words': 225}