; test-with-lg-debug.scm - Test with LG debug output
(use-modules (opencog) (opencog exec) (opencog lg))
(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 "=== LG Debug 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))
; Compare demo-atomese vs dict-pair
(display "=== Testing demo-atomese (known to work) ===\n")
(catch #t
(lambda ()
(define demo-result
(cog-execute!
(LgParseLink
(Phrase "the cat")
(LgDict "demo-atomese")
(Number 3))))
(format #t "demo-atomese result: ~a\n" demo-result)
(format #t "Number of parses: ~a\n\n"
(if (equal? (cog-type demo-result) 'LinkValue)
(length (cog-value->list demo-result))
"N/A")))
(lambda (key . args)
(format #t "Error with demo-atomese: ~a ~a\n\n" key args)))
(display "=== Testing dict-pair (our dictionary) ===\n")
(catch #t
(lambda ()
(define pair-result
(cog-execute!
(LgParseLink
(Phrase "the cat")
(LgDict "dict-pair")
(Number 3)
(cog-atomspace)
rsn)))
(format #t "dict-pair result: ~a\n" pair-result)
(format #t "Number of parses: ~a\n\n"
(if (equal? (cog-type pair-result) 'LinkValue)
(length (cog-value->list pair-result))
"N/A")))
(lambda (key . args)
(format #t "Error with dict-pair: ~a ~a\n\n" key args)))
; Try a simpler test - just check if dictionary lookup works
(display "=== Dictionary Lookup Test ===\n")
(display "Using LgDictEntry to look up 'the' in dict-pair...\n")
(catch #t
(lambda ()
(define entry-result
(cog-execute!
(LgDictEntry
(Word "the")
(LgDict "dict-pair"))))
(format #t "LgDictEntry result: ~a\n" entry-result)
(format #t "Number of entries: ~a\n"
(if (equal? (cog-type entry-result) 'LinkValue)
(length (cog-value->list entry-result))
"N/A")))
(lambda (key . args)
(format #t "Error: ~a ~a\n" key args)))
(cog-close rsn)
(display "\n=== Done ===\n")