<commit_before>#!/usr/bin/env ypsilon
#!r6rs

(import (rnrs (6))
        (match)
        (prefix (lunula log) log:)
        (only (lunula mysql) connect close lookup-all save)
        (only (errata configuration) mysql-user mysql-password mysql-database)
        (only (errata isbn) valid-isbn10?)
        (errata model)
        (only (errata query) query-image))

(define *roll* 1000)

(define (run)
  (let ((tuples (lookup-all (bib) ((bib (image #f))))))
    (unless (null? tuples)
      (call/cc
       (lambda (cont)
         (for-each
          (lambda (tuple)
            (match tuple
              ((b)
               (let ((isbn (bib-isbn10 b)))
                 (when (valid-isbn10? isbn)
                   (let* ((info (guard (e
                                        ((i/o-error? e)
                                         (log:info "image-agent> ~s" e)
                                         (cont #f)))
                                  (query-image isbn)))
                          (new-b (string->bib info)))
                     (cond ((bib-image new-b)
                            => (lambda (url)
                                 (bib-image-set! b url)
                                 ;; Note that possibly the bib no longer exists, thus new one will be created<commit_msg>fixed a missing line<commit_after>#!/usr/bin/env ypsilon
#!r6rs

(import (rnrs (6))
        (only (core) usleep)
        (match)
        (prefix (lunula log) log:)
        (only (lunula mysql) connect close lookup-all save)
        (only (errata configuration) mysql-user mysql-password mysql-database)
        (only (errata isbn) valid-isbn10?)
        (errata model)
        (only (errata query) query-image))

(define *roll* 1000)

(define (run)
  (let ((tuples (lookup-all (bib) ((bib (image #f))))))
    (unless (null? tuples)
      (call/cc
       (lambda (cont)
         (for-each
          (lambda (tuple)
            (match tuple
              ((b)
               (let ((isbn (bib-isbn10 b)))
                 (when (valid-isbn10? isbn)
                   (let* ((info (guard (e
                                        ((i/o-error? e)
                                         (log:info "image-agent> ~s" e)
                                         (cont #f)))
                                  (query-image isbn)))
                          (new-b (string->bib info)))
                     (cond ((bib-image new-b)
                            => (lambda (url)
                                 (bib-image-set! b url)
                                 ;; Note that possibly the bib no longer exists, thus new one will be created
{'fraction_non_alphanumeric': 0.12310030395136778, 'fraction_numerical': 0.00911854103343465, 'mean_word_length': 1.1670781893004116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2847835', 'n_tokens_mistral': 762, 'n_tokens_neox': 719, 'n_words': 213}