<commit_before>(define-module (opencog ghost predicates)
  #:use-module (opencog)
  #:use-module (opencog attention)
  #:use-module (opencog pointmem)
  #:use-module (opencog spacetime)
  #:export (
    ; Sensory input
    perceived-face
    perceived-emotion
    perceive-word

    ; Perceptual predicates
    person_appears
    person_smiles
    person_angry
    word_perceived

    ; Actions
    animation
    expression
    )
)

; Perception and action apis and predicates
; NOTE: This is not organized  as it is still in development.

; --------------------------------------------------------------
; There is a spacemap in eva-model module called faces. Thus the rename.
(define facemap (SpaceMapNode "perceived-faces"))

; --------------------------------------------------------------
; Apis for inputing sensory information.
; --------------------------------------------------------------
(define (perceived-face face-id x y z)
  (cog-pointmem-map-atom facemap (Concept face-id)
    (List (Number x) (Number y) (Number z)))
)

(define (perceived-emotion face-id emotion-type strength)
  (Evaluation (stv strength 1)
    (Predicate emotion-type)
    (List face))
)

(define (perceive-word word)
  *uspecified* 
)

; --------------------------------------------------------------
; Apis for forming GroundedPredicates that are used for 
; checking if the world is in a particular state or not.
; --------------------------------------------------------------
(define (person_appears face-id)
  (cog-pointmem-get-locs-of-atom facemap (Concept face-id))
)

(define (person_smiles)
  *uspecified* 
)

(define (person_angry)
  *uspecified* 
)

(define (word_perceived)
  *uspecified* 
)

; --------------------------------------------------------------
; Apis for forming GroundedSchemas that are use for exectuing
; actions.
; --------------------------------------------------------------
(define (animation)
  *uspecified* 
)

(define (expression)
  *uspecified* 
)<commit_msg>Add person_appears predicate for ghost<commit_after>(define-module (opencog ghost predicates)
  #:use-module (ice-9 optargs)
  #:use-module (opencog)
  #:use-module (opencog attention)
  #:use-module (opencog exec)
  #:use-module (opencog pointmem)
  #:use-module (opencog spacetime)
  #:export (
    ; Sensory input
    perceived-face
    perceived-emotion
    perceive-word

    ; Perceptual predicates
    person_appears
    person_smiles
    person_angry
    word_perceived

    ; Actions
    animation
    expression

    ; Utilities
    is-model-true?
    )
)

; Perception and action apis and predicates
; NOTE: This is not organized  as it is still in development.

; --------------------------------------------------------------
; There is a spacemap in eva-model module called faces. Thus the rename.
;(define facemap (SpaceMapNode "perceived-faces"))

; --------------------------------------------------------------
; Apis used to create the atoms used to represent the world, aka
; world-model. These are not exported.
; --------------------------------------------------------------
(define (see-face face-id)
"
  Define the atom used to represent that the face represented by FACE-ID
  is being seen.
"
  (Evaluation
    (Predicate "see")
    (List
      (Concept "I")
      (Concept face-id)))
)

(define (face-emotion face-id emotion-type)
"
  Define the atom used to represent EMOTION-TYPE of the face with
  id FACE-ID.
"
  (Evaluation
    (Predicate emotion-type)
    (List face-id))
)

; --------------------------------------------------------------
; Apis for inputing sensory information.
; --------------------------------------------------------------
;(define (perceived-face face-id x y z)
;  (cog-pointmem-map-atom facemap (Concept face-id)
;    (List (Number x) (Number y) (Number z)))

(define (perceived-face face-id strength)
  (cog-set-tv! (see-face face-id) (stv strength 1))
)

(define (perceived-emotion face-id emotion-type strength)
  (cog-set-tv! (face-emotion face-id emotion-type) (stv strength 1))
)

(define (perceive-word word)
  *uspecified* 
)

; --------------------------------------------------------------
; Apis for forming GroundedPredicates that are used for 
; checking if the world is in a particular state or not.
; --------------------------------------------------------------
;(define (person_appears face-id)
;  (cog-pointmem-get-locs-of-atom facemap (Concept face-id))
;)

(define* (person_appears #:optional face-id)
  (if face-id
    (is-model-true? (see-face face-id))
    (any-face-seen?)
  )
)

(define (any-face-seen?)
  (define get-models
    (Get
      (TypedVariable (Variable "seen-faces")
      (Signature
        (Evaluation
          (Predicate "see")
          (List
            (Concept "I")
            (Type "ConceptNode")))))
      (And
        (Evaluation
          (GroundedPredicate "scm: is-model-true?")
          (List
            (Variable "seen-faces")))
        (Variable "seen-faces"))))

  (let ((models (cog-outgoing-set (cog-execute! get-models))))
    (if (null? models)
      (stv 0 1)
      (stv 1 1)
    )
  )
)

(define* (person_smiles #:optional face-id)
  (if face-id
    (is-model-true? (face-emotion face-id "smile"))
    (any-person-smiles?)
  )
)

(define (any-person-smiles?)
  *uspecified*
)

(define (person_angry)
  *uspecified*
)

(define (word_perceived)
  *uspecified* 
)

; --------------------------------------------------------------
; Apis for forming GroundedSchemas that are use for exectuing
; actions.
; --------------------------------------------------------------
(define (animation)
  *uspecified* 
)

(define (expression)
  *uspecified* 
)

; --------------------------------------------------------------
; Utilities
; --------------------------------------------------------------
(define (is-model-true? model)
  (let ((strength (tv-mean (cog-tv model))))
    (cond
      ((> 0.5 strength) (stv 0 1))
      ((<= 0.5 strength) (stv 1 1)))
  )
)
{'fraction_non_alphanumeric': 0.2865536343797213, 'fraction_numerical': 0.00268591572939399, 'mean_word_length': 1.5926892950391645, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6069247', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1737, 'n_words': 474}