<commit_before>(define (do-fuzzy-QA)
    (State fuzzy-qa-search search-started)

    (begin-thread
        (let* ((sent-node (get-input-sent-node))
               (ans (get-fuzzy-answers sent-node #:do-microplanning #f)))

            (if (not (null? ans))
                (let ((ans-in-words (List (map Word (car ans)))))
                    (State fuzzy-answers ans-in-words)

                    ; Create a new psi-canned-rule for it
                    (Member
                        (psi-rule
                            (list (SequentialAnd
                                (DefinedPredicate "is-input-utterance?")
                                (Evaluation (GroundedPredicate "scm: did-someone-say-this?") (get-input-word-list))
                            ))
                            (ExecutionOutput (GroundedSchema "scm: say") ans-in-words)
                            (Evaluation (GroundedPredicate "scm: psi-demand-value-maximize") (List sociality (Number "90")))
                            new-rule-tv
                            sociality
                        )
                        canned-rule
                    )
                )
            )
        )
    )
)

(define (do-aiml-search)
    (State aiml-search search-started)

    (begin-thread
        (State aiml-replies (aiml-get-response-wl (get-input-word-list)))
    )
)

(define (say . words)
    (if (list? (car words))
        (display (map cog-name (car words)))
        (display (map cog-name words))
    )

    (reset-all-states)
)

(define (reply anchor)
    (let ((ans (cog-chase-link 'StateLink 'ListLink anchor)))
        (if (null? ans)
            '()
            (say (cog-outgoing-set (car ans)))
        )
    )
)

(define (reset-all-states)
    (State input-utterance no-input-utterance)
    (State canned-rules default-state)
    (State aiml-replies default-state)<commit_msg>py: say<commit_after>(define (do-fuzzy-QA)
    (State fuzzy-qa-search search-started)

    (begin-thread
        (let* ((sent-node (get-input-sent-node))
               (ans (get-fuzzy-answers sent-node #:do-microplanning #f)))

            (if (not (null? ans))
                (let ((ans-in-words (List (map Word (car ans)))))
                    (State fuzzy-answers ans-in-words)

                    ; Create a new psi-canned-rule for it
                    (Member
                        (psi-rule
                            (list (SequentialAnd
                                (DefinedPredicate "is-input-utterance?")
                                (Evaluation (GroundedPredicate "scm: did-someone-say-this?") (get-input-word-list))
                            ))
                            (ExecutionOutput (GroundedSchema "scm: say") ans-in-words)
                            (Evaluation (GroundedPredicate "scm: psi-demand-value-maximize") (List sociality (Number "90")))
                            new-rule-tv
                            sociality
                        )
                        canned-rule
                    )
                )
            )
        )
    )
)

(define (do-aiml-search)
    (State aiml-search search-started)

    (begin-thread
        (State aiml-replies (aiml-get-response-wl (get-input-word-list)))
    )
)

(define (say . words)
    (define utterance "")

    (if (list? (car words))
        (set! utterance (string-join (map cog-name (car words))))
        (set! utterance (string-join (map cog-name words)))
    )

    (display utterance)

    ; Send it via ROS
    (catch #t
        (lambda ()
            (cog-evaluate! (Evaluation (GroundedPredicate "py: say") (List (Node utterance))))
            (cog-extract (Node utterance))
        )
        (lambda (key . parameters)
            (error "ERR: Can't do \"py: say\"?!\n")
        )
    )

    (reset-all-states)
)

(define (reply anchor)
    (let ((ans (cog-chase-link 'StateLink 'ListLink anchor)))
        (if (null? ans)
            '()
            (say (cog-outgoing-set (car ans)))
        )
    )
)

(define (reset-all-states)
    (State input-utterance no-input-utterance)
    (State canned-rules default-state)
    (State aiml-replies default-state)
{'fraction_non_alphanumeric': 0.12755716004813478, 'fraction_numerical': 0.0009626955475330926, 'mean_word_length': 1.3843947217441193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1866266', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1219, 'n_words': 265}