<commit_before>;; This is used to create the include directory.

;; Should be called with three command-line arguments:
;; 1. The include directory that should be created,
;; 2. The location of the src/mzscheme directory,
;; 3. The location of mzconfig.

#lang scheme/base

(define-values (incdir mzsrcdir mzconfdir)
  (let ([args (vector->list (current-command-line-arguments))])
    (define (dir path) (normal-case-path (simplify-path (cleanse-path path))))
    (unless (= 3 (length args)) (error 'mkincludes "bad arguments"))
    (apply values (map dir args))))

(printf "Making ~a\n" incdir)

(define ((change-regexp from to) src dst)
  (call-with-input-file src
    (lambda (src)
      (call-with-output-file dst
        (lambda (dst)
          (when (regexp-match from src 0 #f dst)
            (display to dst)
            (regexp-match "$" src 0 #f dst)))))))

(define (copy-if-newer basedir source-path . args)
  (define (arg!) (and (pair? args) (begin0 (car args) (set! args (cdr args)))))
  (define source (build-path basedir source-path))
  (define target
    (build-path incdir
                (or (arg!)
                    (let-values ([(_1 name _2) (split-path source)]) name))))
  (define source-t (file-or-directory-modify-seconds source))
  (define target-t (and (file-exists? target)
                        (file-or-directory-modify-seconds target)))
  (define copy (or (arg!) copy-file))
  (cond<commit_msg>clean-up for mkincludes to avoid printouts and use optional args<commit_after>;; This is used to create the include directory.

;; Should be called with three command-line arguments:
;; 1. The include directory that should be created,
;; 2. The location of the src/mzscheme directory,
;; 3. The location of mzconfig.

#lang scheme/base

(define-values (incdir mzsrcdir mzconfdir)
  (let ([args (vector->list (current-command-line-arguments))])
    (define (dir path) (normal-case-path (simplify-path (cleanse-path path))))
    (unless (= 3 (length args)) (error 'mkincludes "bad arguments"))
    (apply values (map dir args))))

(printf "Making ~a\n" incdir)

(define ((change-regexp from to) src dst)
  (call-with-input-file src
    (lambda (src)
      (call-with-output-file dst
        (lambda (dst)
          (when (regexp-match from src 0 #f dst)
            (display to dst)
            (regexp-match "$" src 0 #f dst))))))
  (void))

(define (copy-if-newer basedir source-path [base #f] [copy copy-file])
  (define source (build-path basedir source-path))
  (define target
    (build-path incdir
                (or base
                    (let-values ([(_1 name _2) (split-path source)]) name))))
  (define source-t (file-or-directory-modify-seconds source))
  (define target-t (and (file-exists? target)
                        (file-or-directory-modify-seconds target)))
  (cond
{'fraction_non_alphanumeric': 0.13981547196593327, 'fraction_numerical': 0.00603264726756565, 'mean_word_length': 2.981638418079096, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6929630', 'n_tokens_mistral': 908, 'n_tokens_neox': 882, 'n_words': 297}