<commit_before>;;;; metap.lisp
;;;;  
;;;; Copyright 2015 hipeta (<EMAIL>)
;;;;
;;;; This software is released under the MIT License.
;;;; http://opensource.org/licenses/mit-license.php

(in-package :cl-user)
(defpackage metap
  (:use :cl)
  (:import-from :alexandria :compose)
  (:export :*metap-m1-m2-pairs*
           :register-m1-m2-pair
           :clear-m1-m2-pairs))
(in-package :metap)

(defparameter *metap-m1-m2-pairs* nil)

(defun register-m1-m2-pair (m1class m2class)
  (pushnew (cons m1class m2class) *metap-m1-m2-pairs* :test 'equal))

(defun clear-m1-m2-pairs ()
  (setf *metap-m1-m2-pairs* nil))

(defmethod c2mop:ensure-class-using-class :around (class name &rest args
                                                   &key
                                                     direct-default-initargs
                                                     direct-slots
                                                     direct-superclasses
                                                     metaclass &allow-other-keys)
  (flet ((apply-m2class (m1class m2class)
           (let ((allowed-metaclasses `(standard-class ',m2class)))
             (if (and metaclass (member metaclass allowed-metaclasses))
                 (call-next-method class name
                                   :direct-default-initargs direct-default-initargs
                                   :direct-slots direct-slots
                                   :direct-superclasses direct-superclasses
                                   :metaclass m2class)
                 (error "can not specify ~a as metaclass because this class ~a is a subclass of ~a."
                        metaclass name m1class)))))
    (let ((superclasses (mapcan (compose #'c2mop:compute-class-precedence-list #'find-class)
                                direct-superclasses)))
      (loop for (m1class . m2class) in *metap-m1-m2-pairs*
         when (member (find-class m1class) superclasses) return (apply-m2class m1class m2class)
         finally (return (call-next-method))))))
<commit_msg>Add declare ignorable<commit_after>;;;; metap.lisp
;;;;  
;;;; Copyright 2015 hipeta (<EMAIL>)
;;;;
;;;; This software is released under the MIT License.
;;;; http://opensource.org/licenses/mit-license.php

(in-package :cl-user)
(defpackage metap
  (:use :cl)
  (:import-from :alexandria :compose)
  (:export :*metap-m1-m2-pairs*
           :register-m1-m2-pair
           :clear-m1-m2-pairs))
(in-package :metap)

(defparameter *metap-m1-m2-pairs* nil)

(defun register-m1-m2-pair (m1class m2class)
  (pushnew (cons m1class m2class) *metap-m1-m2-pairs* :test 'equal))

(defun clear-m1-m2-pairs ()
  (setf *metap-m1-m2-pairs* nil))

(defmethod c2mop:ensure-class-using-class :around (class name &rest args
                                                   &key
                                                     direct-default-initargs
                                                     direct-slots
                                                     direct-superclasses
                                                     metaclass &allow-other-keys)
  (declare (ignorable args))
  (flet ((apply-m2class (m1class m2class)
           (let ((allowed-metaclasses `(standard-class ',m2class)))
             (if (and metaclass (member metaclass allowed-metaclasses))
                 (call-next-method class name
                                   :direct-default-initargs direct-default-initargs
                                   :direct-slots direct-slots
                                   :direct-superclasses direct-superclasses
                                   :metaclass m2class)
                 (error "can not specify ~a as metaclass because this class ~a is a subclass of ~a."
                        metaclass name m1class)))))
    (let ((superclasses (mapcan (compose #'c2mop:compute-class-precedence-list #'find-class)
                                direct-superclasses)))
      (loop for (m1class . m2class) in *metap-m1-m2-pairs*
         when (member (find-class m1class) superclasses) return (apply-m2class m1class m2class)
         finally (return (call-next-method))))))

{'fraction_non_alphanumeric': 0.11295361691900985, 'fraction_numerical': 0.019226147560682527, 'mean_word_length': 1.5947630922693268, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '163646', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1178, 'n_words': 267}