<commit_before>(in-package :varjo)
(in-readtable fn:fn-reader)

;;-------------------------------------------------------------------------

(defvar *metadata-kinds* nil)

;;-------------------------------------------------------------------------

;; {TODO} proper error
(defmacro def-metadata-kind (name (&key conc-name) &body slot-names)
  (check-metadata-slots slot-names)
  `(progn
     (defclass ,name (standard-value-metadata)
       ,(mapcar λ`(,_ :initform nil :initarg ,(kwd _))
                slot-names))
     ,@(mapcar λ`(defmethod ,(if conc-name (symb conc-name _) _)
                     ((metadata-collection list))
                   (let ((data (cdr (assoc ',name metadata-collection))))
                     (when data
                       (slot-value data ',_))))
               slot-names)
     ,@(mapcar λ`(defmethod ,(if conc-name (symb conc-name _) _)
                     ((metadata ,name))
                   (slot-value metadata ',_))
               slot-names)
     ,(when slot-names (gen-meta-init-check name slot-names))
     (defmethod print-object ((obj ,name) stream)
       (print-unreadable-object (obj stream :type t :identity t)
         (with-slots ,slot-names obj
           (format stream ,(format nil "~{:~a ~~a~^ ~}" slot-names)
                   ,@slot-names))))<commit_msg>emit defgenerics in deftype (squash warnings)<commit_after>(in-package :varjo)
(in-readtable fn:fn-reader)

;;-------------------------------------------------------------------------

(defvar *metadata-kinds* nil)

;;-------------------------------------------------------------------------

;; {TODO} proper error
(defmacro def-metadata-kind (name (&key conc-name) &body slot-names)
  (check-metadata-slots slot-names)
  `(progn
     (defclass ,name (standard-value-metadata)
       ,(mapcar λ`(,_ :initform nil :initarg ,(kwd _))
                slot-names))
     ,@(mapcar λ`(defgeneric ,(if conc-name (symb conc-name _) _) (metadata))
               slot-names)
     ,@(mapcar λ`(defmethod ,(if conc-name (symb conc-name _) _)
                     ((metadata-collection list))
                   (let ((data (cdr (assoc ',name metadata-collection))))
                     (when data
                       (slot-value data ',_))))
               slot-names)
     ,@(mapcar λ`(defmethod ,(if conc-name (symb conc-name _) _)
                     ((metadata ,name))
                   (slot-value metadata ',_))
               slot-names)
     ,(when slot-names (gen-meta-init-check name slot-names))
     (defmethod print-object ((obj ,name) stream)
       (print-unreadable-object (obj stream :type t :identity t)
         (with-slots ,slot-names obj
           (format stream ,(format nil "~{:~a ~~a~^ ~}" slot-names)
                   ,@slot-names))))
{'fraction_non_alphanumeric': 0.241453760345448, 'fraction_numerical': 0.0, 'mean_word_length': 1.5022502250225023, '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': '7030599', 'n_tokens_mistral': 814, 'n_tokens_neox': 775, 'n_words': 188}