<commit_before>(in-package #:parse-number-range)

;; Stupid repetition, but I've had enough.
(defun kind (keyword &key (errorp t))
  '(values kind new-direction new-limit-kind)
  (case keyword
    ((:from :downfrom :upfrom)
     (multiple-value-call #'values
       :from
       (ecase keyword
         (:from (values nil nil))
         (:downfrom (values '- nil))
         (:upfrom (values '+ nil)))))
    ((:to :upto :downto :below :above)
     (multiple-value-call #'values
       :to
       (ecase keyword
         (:to (values nil :inclusive))
         (:downto (values '- :inclusive))
         (:upto (values '+ :inclusive))
         (:below (values '+ :exclusive))
         (:above (values '- :exclusive)))))
    (:by (values :by nil nil))
    (t (when errorp
         (error "~S is not a for-as-arithmetic keyword." keyword)))))

(defun flags (keyword &key (errorp t))
  (multiple-value-call (lambda (kind &rest flags)
                         (declare (ignore kind))
                         (values-list flags))
    (kind keyword :errorp errorp)))


(defun flags-to-keywords (direction limit-kind)
  '(values from-keyword to-keyword)
  (cartesian-product-switch:cartesian-product-switch
      ((ecase direction
         + -)
       (ecase limit-kind
         (nil) :inclusive :exclusive))
    ;; +
    (values :from nil)
    (values :from :to)
    (values :from :below)
    ;; -
    (values :downfrom nil)
    (values :from :downto)
    (values :from :above)))<commit_msg>FLAGS didn't actually need to catch &rest as the number of values (2) is known.<commit_after>(in-package #:parse-number-range)

;; Stupid repetition, but I've had enough.
(defun kind (keyword &key (errorp t))
  '(values kind new-direction new-limit-kind)
  (case keyword
    ((:from :downfrom :upfrom)
     (multiple-value-call #'values
       :from
       (ecase keyword
         (:from (values nil nil))
         (:downfrom (values '- nil))
         (:upfrom (values '+ nil)))))
    ((:to :upto :downto :below :above)
     (multiple-value-call #'values
       :to
       (ecase keyword
         (:to (values nil :inclusive))
         (:downto (values '- :inclusive))
         (:upto (values '+ :inclusive))
         (:below (values '+ :exclusive))
         (:above (values '- :exclusive)))))
    (:by (values :by nil nil))
    (t (when errorp
         (error "~S is not a for-as-arithmetic keyword." keyword)))))

(defun flags (keyword &key (errorp t))
  (multiple-value-bind (kind direction limit-kind)
      (kind keyword :errorp errorp)
    (declare (ignore kind))
    (values direction limit-kind)))


(defun flags-to-keywords (direction limit-kind)
  '(values from-keyword to-keyword)
  (cartesian-product-switch:cartesian-product-switch
      ((ecase direction
         + -)
       (ecase limit-kind
         (nil) :inclusive :exclusive))
    ;; +
    (values :from nil)
    (values :from :to)
    (values :from :below)
    ;; -
    (values :downfrom nil)
    (values :from :downto)
    (values :from :above)))
{'fraction_non_alphanumeric': 0.151, 'fraction_numerical': 0.0003333333333333333, 'mean_word_length': 2.477404403244496, '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': '5669330', 'n_tokens_mistral': 1002, 'n_tokens_neox': 930, 'n_words': 279}