<commit_before>(use-modules (opencog)
             (opencog nlp)
             (opencog nlp chatlang)
             (opencog openpsi)
             (srfi srfi-1))

; Just try a simple one
(define rule (cr '("'<NAME>' 'liked movie") '("Cool")))

; These are the conditions under the AndLink of the SatisfactionLink
; Susceptible to any change in format
(define conditions (cog-outgoing-set (gdr (car (psi-get-context rule)))))

; Each of the terms should have been tested already by now, here
; just check some trivial things... Expand it if needed
(define test-chat-rule-result
    (and (equal? (cog-type rule) 'ImplicationLink)
         (psi-rule? rule)
         ; Check if the conditions below are generated in the rule
         ; This is needed for DualLink to find the rule
         (equal? #t (any (lambda (c)
           (if (equal? 'ListLink (cog-type (gar c)))
               (let ((oset (cog-outgoing-set (gar c))))
                    (and (equal? 'GlobNode (cog-type (first oset)))
                         (equal? 'GlobNode (cog-type (last oset)))
                         (equal? (list (Word "James")
                                       (Word "Gilbert")
                                       (Word "like")
                                       (Word "movie"))
                                 (cog-filter 'WordNode oset))))
               #f)) conditions))
         ; This is needed one of the shared conditions
         (list? (member (State (Anchor "Chatlang: Currently Processing")
                               (Variable "$S"))
                        conditions))
         ; This is another shared conditions
         (list? (member (Parse (Variable "$P") (Variable "$S"))
                        conditions))))
         ; Including this causes a failure in cxxtest for no reason
         ; (equal? (gaddr (psi-get-action rule)) (Node "Cool"))))<commit_msg>Fix utest<commit_after>(use-modules (opencog)
             (opencog nlp)
             (opencog nlp chatlang)
             (opencog openpsi)
             (srfi srfi-1))

; Just try a simple one
(define rule (cr '("'<NAME>' 'liked movie") '("Cool")))

; These are the conditions under the AndLink of the SatisfactionLink
; Susceptible to any change in format
(define conditions (cog-outgoing-set (gdr (car (psi-get-context rule)))))

; Each of the terms should have been tested already by now, here
; just check some trivial things... Expand it if needed
(define test-chat-rule-result
    (and (equal? (cog-type rule) 'ImplicationLink)
         (psi-rule? rule)
         ; Check if the conditions below are generated in the rule
         ; This is needed for DualLink to find the rule
         (equal? #t (any (lambda (c)
           (if (equal? 'ListLink (cog-type c))
               (let ((oset (cog-outgoing-set c)))
                    (and (equal? 'GlobNode (cog-type (first oset)))
                         (equal? 'GlobNode (cog-type (last oset)))
                         (equal? (list (Word "James")
                                       (Word "Gilbert")
                                       (Word "like")
                                       (Word "movie"))
                                 (cog-filter 'WordNode oset))))
               #f)) conditions))
         ; This is needed one of the shared conditions
         (list? (member (State (Anchor "Chatlang: Currently Processing")
                               (Variable "$S"))
                        conditions))
         ; This is another shared conditions
         (list? (member (Parse (Variable "$P") (Variable "$S"))
                        conditions))))
         ; Including this causes a failure in cxxtest for no reason
         ; (equal? (gaddr (psi-get-action rule)) (Node "Cool"))))
{'fraction_non_alphanumeric': 0.11182450508293205, 'fraction_numerical': 0.0005350454788657035, 'mean_word_length': 1.6517730496453902, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3731716', 'n_tokens_mistral': 1015, 'n_tokens_neox': 978, 'n_words': 366}