<commit_before>(in-package #:unicode-base)


(defclass char-code-unit-string (#+string-is-utf-8  utf-8-string
                                 #+string-is-utf-16 utf-16-string
                                 #+string-is-utf-32 utf-32-string)
  ((string :type 'string
           :initarg :string
           :reader code-unit-string-string))
  (:documentation "A string of chararacter objects as code units."))


(defmethod custring ((string string))
  (make-instance 'char-code-unit-string :string string))


(defun cuchar (char-code-unit-string index)
  "Like char, but for char-code-code-unit-string objects."
  (char (code-unit-string-string char-code-unit-string) index))


(defmethod culength ((custring char-code-unit-string))
  (length (code-unit-string-string custring)))


(defmethod curef ((custring char-code-unit-string) index)
  (char-code (cuchar custring index)))<commit_msg>string*<commit_after>(in-package #:unicode-base)


(defclass char-code-unit-string (#+string-is-utf-8  utf-8-string
                                 #+string-is-utf-16 utf-16-string
                                 #+string-is-utf-32 utf-32-string)
  ((string :type 'string
           :initarg :string
           :reader code-unit-string-string))
  (:documentation "A string of chararacter objects as code units."))


(defgeneric string* (x)
  (:method ((x string)) x)
  (:method (x)
    (map 'string
         #'code-char
         #+string-is-utf-8 (utf-8-vector x)
         #+string-is-utf-16 (utf-16-vector x)
         #+string-is-utf-32 (code-point-vector x))))


(defmethod custring ((string string))
  (make-instance 'char-code-unit-string :string string))


(defun cuchar (char-code-unit-string index)
  "Like char, but for char-code-code-unit-string objects."
  (char (code-unit-string-string char-code-unit-string) index))


(defmethod culength ((custring char-code-unit-string))
  (length (code-unit-string-string custring)))


(defmethod curef ((custring char-code-unit-string) index)
  (char-code (cuchar custring index)))
{'fraction_non_alphanumeric': 0.14780029658922392, 'fraction_numerical': 0.01384083044982699, 'mean_word_length': 2.748148148148148, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '947729', 'n_tokens_mistral': 687, 'n_tokens_neox': 653, 'n_words': 148}