Skip to content

Commit

Permalink
Merge pull request opencog#3241 from ngeiswei/swap-cog-tv-mean
Browse files Browse the repository at this point in the history
Swap cog-tv-mean with cog-mean
  • Loading branch information
ngeiswei authored Jun 29, 2018
2 parents 9cf4f10 + c6cffde commit dfe3923
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions opencog/ghost/procedures/procedures.scm
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
)

(define (record-perception model new-conf)
(let ((old-conf (cog-tv-confidence (cog-tv model)))
(let ((old-conf (cog-confidence (cog-tv model)))
(time (FloatValue (current-time-us))))

(if percep (begin
Expand Down Expand Up @@ -562,7 +562,7 @@
; It is better to find the product of the strength and confidence but for now
; confidence is used as the default stv for new atoms is (stv 1 0), so
; need to waste cpu cycles.
(let ((conf (cog-tv-confidence (cog-tv model))))
(let ((conf (cog-confidence (cog-tv model))))
(if (true-value? conf)
(stv 1 1)
(stv 0 1)
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/aiml/aiml.scm
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
;; some weighting formula that makes more sense tahn this.
;; Currently, the square of the confidence.
(define (get-weight ATOM)
(define w (cog-tv-confidence (cog-tv ATOM)))
(define w (cog-confidence (cog-tv ATOM)))
(* w w)
)

Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/chatbot-psi/contexts.scm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

(define (check-aiml-reply num-node)
(let* ((tv (cog-tv (aiml-get-selected-rule)))
(conf (cog-tv-confidence tv))
(conf (cog-confidence tv))
(threshold (string->number (cog-name num-node))))
(if (> conf threshold)
(stv 1 1)
Expand Down
4 changes: 2 additions & 2 deletions opencog/nlp/chatbot-psi/pln-actions.scm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
;; return atom.tv.s^2*atom.tv.c
(define (higest-tv-fitness atom)
(let* ((tv (cog-tv atom))
(tv-s (cog-tv-mean tv))
(tv-c (cog-tv-confidence tv))
(tv-s (cog-mean tv))
(tv-c (cog-confidence tv))
(res (* tv-s tv-s tv-c)))
;; (cog-logger-info "higest-tv-fitness(~a) = ~a" atom res)
res))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
(prt-distribution nmemb))

(define (get-count atom)
(if (cog-atom? atom) (cog-tv-count (cog-tv atom)) 0))
(if (cog-atom? atom) (cog-count (cog-tv atom)) 0))

; Print disjunct support distribution, viz, number of distinct different
; disjuncts on each class
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/learn/notes
Original file line number Diff line number Diff line change
Expand Up @@ -3175,7 +3175,7 @@ https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26616
(cog-value atom key)
(cog-value?
cog-value->list
cog-tv-count
cog-count

confidence

Expand Down
6 changes: 3 additions & 3 deletions opencog/nlp/learn/scm/batch-word-pair.scm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
(let ((all-pairs '()))

; Get the observational count on ATOM.
(define (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define (get-count ATOM) (cog-count (cog-tv ATOM)))

(define any-left (AnyNode "left-word"))
(define any-right (AnyNode "right-word"))
Expand Down Expand Up @@ -233,7 +233,7 @@
(let ((all-pairs '()))

; Get the observational count on ATOM.
(define (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define (get-count ATOM) (cog-count (cog-tv ATOM)))

(define any-left (AnyNode "left-word"))
(define any-right (AnyNode "right-word"))
Expand Down Expand Up @@ -358,7 +358,7 @@
(all-pairs '()))

; Get the observational count on ATOM.
(define (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define (get-count ATOM) (cog-count (cog-tv ATOM)))

; Get the numeric distance from the ExecutionLink
(define (get-dist ATOM)
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/learn/scm/common.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
(define pair-dist (SchemaNode "*-Pair Distance-*"))

; get-count ATOM - return the raw observational count on ATOM.
(define-public (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define-public (get-count ATOM) (cog-count (cog-tv ATOM)))

; set-count ATOM CNT - Set the raw observational count on ATOM.
(define (set-count ATOM CNT) (cog-set-tv! ATOM (cog-new-ctv 1 0 CNT)))
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/learn/scm/connector-vec.scm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
(define (get-pair-type) 'Section)

; Get the observational count on Section SECT
(define (get-count SECT) (cog-tv-count (cog-tv SECT)))
(define (get-count SECT) (cog-count (cog-tv SECT)))

; L-ATOM is a WordNode. R-ATOM is a wild-card.
; Disassemble the R-ATOM, insert L-ATOM into the variable
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/learn/scm/pseudo-csets.scm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
(let ((all-csets '()))

; Get the observational count on ATOM
(define (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define (get-count ATOM) (cog-count (cog-tv ATOM)))

(define any-left (AnyNode "cset-word"))
(define any-right (AnyNode "cset-disjunct"))
Expand Down
4 changes: 2 additions & 2 deletions opencog/nlp/microplanning/anaphora-noun-item.scm
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@
(set! subsets (filter (lambda (l) (word-inst-is-noun? (r2l-get-word-inst (gar l)))) subsets))

; remove close to false or low confidence links base on TruthValue
(set! subsets (filter (lambda (l) (and (> (cog-tv-mean (cog-tv l)) 0.5) (> (cog-tv-confidence (cog-tv l)) 0.5))) subsets))
(set! subsets (filter (lambda (l) (and (> (cog-mean (cog-tv l)) 0.5) (> (cog-confidence (cog-tv l)) 0.5))) subsets))

(let* ((weights
; calculate a weight for each link
(map (lambda (l) (length (cog-incoming-set (gar l))) * (cog-tv-mean (cog-tv l)) * (cog-tv-confidence (cog-tv l))) subsets))
(map (lambda (l) (length (cog-incoming-set (gar l))) * (cog-mean (cog-tv l)) * (cog-confidence (cog-tv l))) subsets))
(sorted-zip
; sort bases on the weight
(sort (zip weights (map gar subsets)) (lambda (s1 s2) (> (car s1) (car s2)))))
Expand Down
4 changes: 2 additions & 2 deletions opencog/nlp/relex2logic/tv-utilities.scm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
(new-conf (/ 1 (+ 1 default-k))))
(cog-set-tv! atom (cog-new-stv new-mean new-conf))
)
(let* ((current-count (cog-tv-count (cog-tv atom)))
(let* ((current-count (cog-count (cog-tv atom)))
(new-count (+ current-count 1))
(new-mean (/ new-count type-count))
(new-conf (/ new-count (+ new-count default-k))))
Expand All @@ -92,7 +92,7 @@
"
(let ((tv (cog-tv atom)))

(cog-set-tv! atom (etv (+ 1 (tv-positive-count tv)) (cog-tv-count tv)))
(cog-set-tv! atom (etv (+ 1 (tv-positive-count tv)) (cog-count tv)))
)
)

Expand Down
6 changes: 3 additions & 3 deletions opencog/nlp/ull-parser/scm/batch-word-pair.scm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
(let ((all-pairs '()))

; Get the observational count on ATOM.
(define (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define (get-count ATOM) (cog-count (cog-tv ATOM)))

(define any-left (AnyNode "left-word"))
(define any-right (AnyNode "right-word"))
Expand Down Expand Up @@ -205,7 +205,7 @@
(let ((all-pairs '()))

; Get the observational count on ATOM.
(define (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define (get-count ATOM) (cog-count (cog-tv ATOM)))

(define any-left (AnyNode "left-word"))
(define any-right (AnyNode "right-word"))
Expand Down Expand Up @@ -318,7 +318,7 @@
(all-pairs '()))

; Get the observational count on ATOM.
(define (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define (get-count ATOM) (cog-count (cog-tv ATOM)))

; Get the numeric distance from the ExecutionLink
(define (get-dist ATOM)
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/ull-parser/scm/common.scm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
(define pair-dist (SchemaNode "*-Pair Distance-*"))

; get-count ATOM - return the raw observational count on ATOM.
(define-public (get-count ATOM) (cog-tv-count (cog-tv ATOM)))
(define-public (get-count ATOM) (cog-count (cog-tv ATOM)))

; set-count ATOM CNT - Set the raw observational count on ATOM.
(define (set-count ATOM CNT) (cog-set-tv! ATOM (cog-new-ctv 1 0 CNT)))
Expand Down
4 changes: 2 additions & 2 deletions opencog/openpsi/action-selector.scm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
and confidence.
"
(let ((rule-stv (cog-tv RULE)))
(* (cog-tv-confidence rule-stv) (cog-tv-mean rule-stv))
(* (cog-confidence rule-stv) (cog-mean rule-stv))
)
)

Expand All @@ -63,7 +63,7 @@
confidence, and short-term-importance.
"
(let ((a-stv (cog-tv RULE)))
(* (cog-tv-confidence a-stv) (cog-tv-mean a-stv) (cog-av-sti RULE))
(* (cog-confidence a-stv) (cog-mean a-stv) (cog-av-sti RULE))
)
)

Expand Down
4 changes: 2 additions & 2 deletions opencog/openpsi/control.scm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"
(MemberLink psi-rule psi-controller-demand)

(psi-rule-set-atomese-weight psi-rule (cog-tv-mean (cog-tv psi-rule)))
(psi-rule-set-atomese-weight psi-rule (cog-mean (cog-tv psi-rule)))

(psi-rule-set-alias! psi-rule name)

Expand Down Expand Up @@ -191,7 +191,7 @@
(if (not (null? result))
(cog-set-tv! rule
(stv (string->number (cog-name (car result)))
(cog-tv-confidence (cog-tv rule))))
(cog-confidence (cog-tv rule))))
)
))

Expand Down
6 changes: 3 additions & 3 deletions opencog/openpsi/demand.scm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
The DEMAND must be a demand node that was previously declared to
the system. The VALUE must be a floating-point number between [0, 1].
"
(cog-set-tv! demand-node (stv demand-value (cog-tv-confidence (cog-tv demand-node))))
(cog-set-tv! demand-node (stv demand-value (cog-confidence (cog-tv demand-node))))
)

; --------------------------------------------------------------
Expand All @@ -137,7 +137,7 @@
RATE must be a NumberNode, holding the percentage change by which
the demand-value will be updated with, on each step.
"
(let* ((strength (cog-tv-mean (cog-tv demand-node)))
(let* ((strength (cog-mean (cog-tv demand-node)))
(rate (/ (string->number (cog-name rate-node)) 100))
(demand-value (+ strength (* strength rate))))
(psi-set-demand-value demand-node demand-value)
Expand All @@ -155,7 +155,7 @@
RATE must be a NumberNode holding the percentage change by which
the demand-value will be updated with, on each step.
"
(let* ((strength (cog-tv-mean (cog-tv demand-node)))
(let* ((strength (cog-mean (cog-tv demand-node)))
(rate (/ (string->number (cog-name rate-node)) 100))
(demand-value (- strength (* strength rate))))
(psi-set-demand-value demand-node demand-value)
Expand Down
8 changes: 4 additions & 4 deletions opencog/openpsi/dynamics/utilities.scm
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
(if (and (cog-atom? result) (eq? 'NumberNode (cog-type result)))
(set! result (string->number (cog-name result))))
; if result is a tv and confidenct is 0, means that it has not been set
(if (and (cog-tv? result) (> (cog-tv-confidence result) 0))
(set! result (cog-tv-mean result)))
(if (and (cog-tv? result) (> (cog-confidence result) 0))
(set! result (cog-mean result)))
(if (not (number? result))
(set! result #f))
;(format #t "return result: ~a\n" result)
Expand Down Expand Up @@ -159,7 +159,7 @@
; else value representation type is not yet set
;begin
; Check if value is stored in StateLink, which is the default
(if (eq? (cog-tv-mean
(if (eq? (cog-mean
(cog-evaluate!
(Satisfaction
(State
Expand All @@ -178,7 +178,7 @@
(if (or (equal? atom-type 'PredicateNode)
(equal? atom-type 'GroundedPredicateNode)
(equal? atom-type 'DefinedPredicateNode))
(let ((confidence (cog-tv-confidence
(let ((confidence (cog-confidence
(cog-evaluate! (Evaluation entity (List))))))
(if (not (eq? confidence 0))
(begin
Expand Down
4 changes: 2 additions & 2 deletions opencog/openpsi/rule.scm
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@
; stv-list, for the purpose of estimating the truthvalue of a
; context when it is true.
(stv
(fold * 1 (map (lambda (x) (cog-tv-mean x)) stv-list))
(fold min 1 (map (lambda (x) (cog-tv-confidence x)) stv-list)))
(fold * 1 (map (lambda (x) (cog-mean x)) stv-list))
(fold min 1 (map (lambda (x) (cog-confidence x)) stv-list)))
)

; map-in-order is used to simulate AndLink assuming
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@

;; Given various TVs calculate the TV of Q(a)
(define (conditional-full-instantiation-tv-formula Pinst-tv Impl-tv P-tv)
(let* ((Impl-s (cog-tv-mean Impl-tv))
(Impl-c (cog-tv-confidence Impl-tv))
(P-s (cog-tv-mean P-tv))
(P-c (cog-tv-confidence P-tv))
(let* ((Impl-s (cog-mean Impl-tv))
(Impl-c (cog-confidence Impl-tv))
(P-s (cog-mean P-tv))
(P-c (cog-confidence P-tv))
;; Hacks to overcome the lack of distributional TV. If s=1
;; and c=0, then assign s to the mode value satisfying the
;; deduction consistency constraint (what a pain, let's use
;; 0.25 for now).
(P-s (if (and (< 0.99 P-s) (<= P-c 0)) 0.25 P-s))
(Pinst-s (cog-tv-mean Pinst-tv))
(Pinst-c (cog-tv-confidence Pinst-tv))
(Pinst-s (cog-mean Pinst-tv))
(Pinst-c (cog-confidence Pinst-tv))
(Qinst-s (* Impl-s Pinst-s))
;; (Qinst-c (* Impl-c Pinst-c (if (< 0 P-c ) (- 1 P-s) 1))))
(Qinst-c (* Impl-c Pinst-c (if (< 0.99 Qinst-s) 1 (- 1 P-s)))))
Expand Down Expand Up @@ -231,7 +231,7 @@
(Impl-tv (cog-tv Impl))
(P-tv (cog-tv P))
(Qinst-tv (conditional-full-instantiation-tv-formula Pinst-tv Impl-tv P-tv)))
(if (< 0 (cog-tv-confidence Qinst-tv)) ; avoid creating informationless knowledge
(if (< 0 (cog-confidence Qinst-tv)) ; avoid creating informationless knowledge
(cog-merge-hi-conf-tv! Qinst Qinst-tv))))

;; Name the implication scope meta rule
Expand Down Expand Up @@ -346,7 +346,7 @@
(Impl-tv (cog-tv Impl))
(P-tv (cog-tv P))
(Qinst-tv (conditional-full-instantiation-tv-formula Pinst-tv Impl-tv P-tv)))
(if (< 0 (cog-tv-confidence Qinst-tv)) ; avoid creating informationless knowledge
(if (< 0 (cog-confidence Qinst-tv)) ; avoid creating informationless knowledge
(cog-merge-hi-conf-tv! Qinst Qinst-tv))))

;; Generate and name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

(define (universal-full-instantiation-forall-formula Pinst Forall)
(let* ((Forall-tv (cog-tv Forall)))
(if (< 0 (cog-tv-confidence Forall-tv)) ; avoid creating informationless knowledge
(if (< 0 (cog-confidence Forall-tv)) ; avoid creating informationless knowledge
(cog-merge-hi-conf-tv! Pinst Forall-tv))))

;; Name the forall scope meta rule
Expand Down
4 changes: 2 additions & 2 deletions opencog/pln/rules/predicate/conditional-direct-evaluation.scm
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
(let* ;; TODO replace by a distributional TV based calculation.
((K 800) ; parameter to convert from count to confidence
(true-enough? (lambda (A) (let* ((TV (cog-tv A))
(s (cog-tv-mean TV))
(c (cog-tv-confidence TV)))
(s (cog-mean TV))
(c (cog-confidence TV)))
(and (> s 0.5) (> c 0)))))
(both-true-enough? (lambda (pair) (and (true-enough? (car pair))
(true-enough? (cadr pair)))))
Expand Down
4 changes: 2 additions & 2 deletions opencog/pln/rules/wip/implication-direct-evaluation.scm
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
(define (true-enough? A)
(let* (
(TV (cog-tv A))
(s (cog-tv-mean TV))
(c (cog-tv-confidence TV)))
(s (cog-mean TV))
(c (cog-confidence TV)))
(and (> s 0.5) (> c 0))))

(define (implication-direct-evaluation-formula P Q)
Expand Down

0 comments on commit dfe3923

Please sign in to comment.