OverviewFilesCommitsIssuesDocsReleasesPeers

hypercore-kb / opencog-kb / language-learning / mvp / test-edge-values.scm

34 lines · scm ref:
;;
;; test-edge-values.scm — Check for malformed edge values
;;

(let ((good 0) (bad 0) (novalue 0)
      (count-key (Predicate "*-TruthValueKey-*"))
      (bad-examples '()))
  (for-each
    (lambda (e)
      (let ((v (cog-value e count-key)))
        (cond
          ((not v) (set! novalue (+ novalue 1)))
          ((catch #t
             (lambda () (cog-value-ref v 2) #t)
             (lambda args #f))
           (set! good (+ good 1)))
          (else
           (set! bad (+ bad 1))
           (when (< (length bad-examples) 5)
             (set! bad-examples (cons (list e v) bad-examples)))))))
    (cog-get-atoms 'Edge))
  (format #t "~%Edge value check:~%")
  (format #t "  Good (index 2 accessible): ~a~%" good)
  (format #t "  Bad (index 2 fails): ~a~%" bad)
  (format #t "  No value: ~a~%" novalue)
  (format #t "  Total: ~a~%" (+ good bad novalue))
  (when (> (length bad-examples) 0)
    (format #t "~%Bad edge examples:~%")
    (for-each
      (lambda (pair)
        (format #t "  Edge: ~a~%" (car pair))
        (format #t "  Value: ~a~%~%" (cadr pair)))
      bad-examples)))