<commit_before>;
; utilities.scm
;
; Miscellaneous handy utilities.
;
; Copyright (c) 2008 <NAME> <<EMAIL>>
;
;

(use-modules (srfi srfi-1))

(define (stv mean conf) (cog-new-stv mean conf))
(define (itv lower upper conf) (cog-new-itv lower upper conf))
(define (ctv mean conf count) (cog-new-ctv mean conf count))

; -----------------------------------------------------------------------
; analogs of car, cdr, etc. but for atoms.
(define (gar x) (if (cog-atom? x) (car (cog-outgoing-set x)) (car x)))
(define (gdr x) (if (cog-atom? x) (cdr (cog-outgoing-set x)) (cdr x)))
(define (gadr x) (if (cog-atom? x) (cadr (cog-outgoing-set x)) (cadr x)))<commit_msg>added mtv helper in scm/utilities.scm<commit_after>;
; utilities.scm
;
; Miscellaneous handy utilities.
;
; Copyright (c) 2008 <NAME> <<EMAIL>>
;
;

(use-modules (srfi srfi-1))

(define (stv mean conf) (cog-new-stv mean conf))
(define (itv lower upper conf) (cog-new-itv lower upper conf))
(define (ctv mean conf count) (cog-new-ctv mean conf count))
; Helper to create CompositeTV
; one can use it 2 ways
; 1) (mtv vh tv) where vh is a versionHandle and tv is TruthValue
; 2) (mtv (cons vh1 tv1) ... (cons vhn tvn))
(define (mtv . x)
  (let ((head (car x)) (tail (cdr x)))
    (if (pair? head) (cog-set-vtv! (mtv tail) (car head) (cdr head))
        (cog-new-mtv head (cadr x)))))

; -----------------------------------------------------------------------
; analogs of car, cdr, etc. but for atoms.
(define (gar x) (if (cog-atom? x) (car (cog-outgoing-set x)) (car x)))
(define (gdr x) (if (cog-atom? x) (cdr (cog-outgoing-set x)) (cdr x)))
(define (gadr x) (if (cog-atom? x) (cadr (cog-outgoing-set x)) (cadr x)))
{'fraction_non_alphanumeric': 0.2519402985074627, 'fraction_numerical': 0.008955223880597015, 'mean_word_length': 2.675438596491228, 'pattern_counts': {'":': 0, '<': 9, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7428707', 'n_tokens_mistral': 664, 'n_tokens_neox': 644, 'n_words': 216}