<commit_before>(in-package :robray)


(defun load-trajectory-data (place)
  (etypecase place
    (rope (with-open-file (stream (rope-string place) :direction :input)
            (load-trajectory-data stream)))
    (stream
     (loop for line = (read-line place nil nil)
        while line
        collect (parse-float-sequence line)))))


(defun %load-trajectory (stream names time time-step default-map clip-start)
  ;; find header
  (let ((lineno 0))
    (unless names
      (block find-header
        (loop for line = (progn (incf lineno)
                                (read-line stream nil nil))
           while line
           for line2 = (strip-hash-comment line)
           do (when line2
                (setq names (split-spaces line2))
                (return-from find-header))))
      (when (equalp (car names) "time")
        (setq names (cdr names))))
    ;; load data
    (keyframe-set
     (loop for line = (progn (incf lineno)
                             (read-line stream nil nil))
        for i from 0
        while line
        for line2 = (strip-hash-comment line)
        when line2
        collect (let ((line-data (parse-float-sequence line2)))
                  (multiple-value-bind (time config)
                      (if time-step
                          (values (+ time (* i time-step))
                                  line-data)
                          (values (car line-data)
                                  (cdr line-data)))
                    (joint-keyframe time
                                    (pairlist-configuration-map names config default-map))))))
    :clip-start clip-start))

(defun load-trajectory (place &key names default-map (time 0d0) time-step clip-start)
  (labels ((helper (stream)
             (%load-trajectory stream names time time-step default-map clip-start)))
    (etypecase place
      (rope
       (with-open-file (stream (rope-string place) :direction :input)
         (helper stream)))
      (stream
       (helper place)))))
<commit_msg>Fix trajectory load result<commit_after>(in-package :robray)


(defun load-trajectory-data (place)
  (etypecase place
    (rope (with-open-file (stream (rope-string place) :direction :input)
            (load-trajectory-data stream)))
    (stream
     (loop for line = (read-line place nil nil)
        while line
        collect (parse-float-sequence line)))))


(defun %load-trajectory (stream names time time-step default-map clip-start)
  ;; find header
  (let ((lineno 0))
    (unless names
      (block find-header
        (loop for line = (progn (incf lineno)
                                (read-line stream nil nil))
           while line
           for line2 = (strip-hash-comment line)
           do (when line2
                (setq names (split-spaces line2))
                (return-from find-header))))
      (when (equalp (car names) "time")
        (setq names (cdr names))))
    ;; load data
    (keyframe-set
     (loop for line = (progn (incf lineno)
                             (read-line stream nil nil))
        for i from 0
        while line
        for line2 = (strip-hash-comment line)
        when line2
        collect (let ((line-data (parse-float-sequence line2)))
                  (multiple-value-bind (time config)
                      (if time-step
                          (values (+ time (* i time-step))
                                  line-data)
                          (values (car line-data)
                                  (cdr line-data)))
                    (joint-keyframe time
                                    (pairlist-configuration-map names config default-map)))))
     :clip-start clip-start)))

(defun load-trajectory (place &key names default-map (time 0d0) time-step clip-start)
  (labels ((helper (stream)
             (%load-trajectory stream names time time-step default-map clip-start)))
    (etypecase place
      (rope
       (with-open-file (stream (rope-string place) :direction :input)
         (helper stream)))
      (stream
       (helper place)))))

{'fraction_non_alphanumeric': 0.10880316518298715, 'fraction_numerical': 0.004945598417408506, 'mean_word_length': 1.6317501626545219, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1636350', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1113, 'n_words': 337}