-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsummary.scm
84 lines (67 loc) · 2.19 KB
/
summary.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;
; summary.scm
;
; Print a summary report for a dataset.
; XXX This is stale and semi-abandoned and needs to be modernized.
;
; Copyright (c) 2017 Linas Vepstas
;
; ---------------------------------------------------------------------
; OVERVIEW
; --------
; Print a summary report for a dataset.
(use-modules (opencog))
(use-modules (opencog matrix))
; ---------------------------------------------------------------------
(define-public (print-sentence-report)
"
print-sentence-report - Summarize sentences.
"
(define n-sent (get-sentence-count))
(define n-parse (get-parse-count))
(if (eqv? 0.0 n-sent)
(throw 'no-sentences 'print-sentence-report
"Atomspace does not contain any SentenceNodes\n"))
(format #t "Sentences: ~A Parses per sentence: ~6f\n"
n-sent (/ n-parse n-sent))
(format #t "Unique words: ~A\n" (length (get-all-words)))
)
; ---------------------------------------------------------------------
(define-public (print-word-pair-report)
"
print-word-pair-report - Summarize properties about word-pairs.
"
(define any-pairs-obj (make-any-link-api))
(define wild-obj (add-pair-stars any-pairs-obj))
(define pca (add-support-api wild-obj))
(define nww (pca 'wild-wild-count))
; Fetch them, if needed.
(if (eqv? 0.0 nww)
(begin
; XXX FIXME work on the singletons API so that we don't
; need to fetch the words.
(display "Start loading words ...\n")
(call-only-once fetch-all-words)
(display "Done loading words\n")
(fetch-atom (any-pairs-obj 'wild-wild))
(set! nww (pca 'wild-wild-count))))
(if (eqv? 0.0 nww)
(throw 'no-word-pairs 'print-word-pair-report
"Atomspace does not contain any word pairs\n"))
(format #t "Word pair observations: ~A\n" nww)
(print-matrix-summary-report any-pairs-obj #t)
)
; ---------------------------------------------------------------------
(define-public (print-language-report)
"
print-language-report -- print a summary report describing the
contents of the atomspace. Intended to summary language-learning
status.
"
(catch #t (print-sentence-report)
(lambda (key . args)
(format #t "~A: ~A: ~A \n" key (car args) (cadr args))
#f
))
)
; ---------------------------------------------------------------------