; test-config-values.scm - Check what config values LG is using
(use-modules (opencog) (opencog exec) (opencog lg))
(use-modules (srfi srfi-1))
(use-modules (opencog persist) (opencog persist-rocks))
(use-modules (opencog matrix) (opencog learn))
; Type aliases
(define (ParseNode name) (Anchor (string-append "parse:" name)))
(define (SentenceNode name) (Anchor (string-append "sentence:" name)))
(module-define! (resolve-module '(opencog lg)) 'ParseNode ParseNode)
(module-define! (resolve-module '(opencog lg)) 'SentenceNode SentenceNode)
(display "=== Config Values Test ===\n\n")
; Load data
(display "Loading data...\n")
(define rsn (RocksStorageNode "rocks://data/pairs.rdb"))
(cog-open rsn)
(define ala (make-any-link-api))
(define aca (add-count-api ala))
(define pair-stars (add-pair-stars aca))
(pair-stars 'fetch-pairs)
(format #t "Loaded ~a edges\n\n" (cog-count-atoms 'Edge))
; Check MI values in our data
(display "=== MI Values in Data ===\n")
(define mi-key (Predicate "*-Mutual Info Key-*"))
(define sample-edges (take (cog-get-atoms 'Edge) 10))
(for-each
(lambda (edge)
(let ((mi-val (cog-value edge mi-key)))
(if mi-val
(let ((mi-list (cog-value->list mi-val)))
(when (>= (length mi-list) 2)
(format #t " ~a: MI=~a\n"
(cog-outgoing-set edge)
(list-ref mi-list 1))))
(format #t " ~a: NO MI VALUE\n" (cog-outgoing-set edge)))))
sample-edges)
; Check the specific "the cat" pair
(display "\n=== Specific pair: (the, cat) ===\n")
(define the-cat-list (List (Word "the") (Word "cat")))
(define the-cat-edge (cog-link 'Edge (Bond "ANY") the-cat-list))
(if the-cat-edge
(begin
(format #t "Edge found: ~a\n" the-cat-edge)
(let ((mi-val (cog-value the-cat-edge mi-key)))
(if mi-val
(format #t "MI value: ~a\n" (cog-value->list mi-val))
(display "NO MI VALUE!\n"))))
(display "Edge NOT found!\n"))
; Try LgHaveDictEntry to see if the word is recognized
(display "\n=== Dictionary Recognition Test ===\n")
(define dict (LgDict "dict-pair"))
; Test if 'the' is in dictionary
(display "Testing if 'the' is in dict-pair...\n")
(catch #t
(lambda ()
(define have-entry (LgHaveDictEntry (Word "the") dict))
(format #t " LgHaveDictEntry link: ~a\n" have-entry)
(define result (cog-evaluate! have-entry))
(format #t " Result: ~a\n" result))
(lambda (key . args)
(format #t " Error: ~a ~a\n" key args)))
(cog-close rsn)
(display "\n=== Done ===\n")