OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-agents commits / 7e01753

More work on the streaming parsing demo
7e01753c670c6fb7f4537b9b1cdab795363df312
by Linas Vepštas <linasvepstas@gmail.com> · 2024-04-16T23:18:43.000Z

Changed files (1) +21 -2

scm/pair-agent/count-agent.scm +21 -2
……@@ -110,14 +110,32 @@
110110 (cog-extract-recursive! phrali)
111111)
112112
113; Parse contents of a file.
113114(define (obs-file FILE-NAME)
114115 (define txt-stream (ValueOf (Concept "foo") (Predicate "some place")))
115116 (define parser (make-parser txt-stream))
116117
117118 (define phrali (FileRead (string-append "file://" FILE-NAME)))
118 (cog-set-value! (Concept "foo") (Predicate "some place") phrali)
119119
120 (cog-execute! parser)
120 ; This will do the trick to set the value. Except it creates an Atom
121 ; (cog-execute!
122 ; (SetValue (Concept "foo") (Predicate "some place")
123 ; (FileRead "file:///tmp/demo.txt")))
124 ; Same as bove, without creating Atom.
125 (cog-set-value! (Concept "foo") (Predicate "some place")
126 (cog-execute! phrali))
127
128 ; Parse only first line of file:
129 ; (cog-execute! parser)
130
131 ; Loop over all lines.
132 (define (looper) (cog-execute! parser) (looper))
133
134 ; At end of file, exception will be thrown. Catch it.
135 (catch #t looper
136 (lambda (key . args) (format #t "The end ~A\n" key)))
137
138 (cog-extract-recursive! phrali)
121139)
122140
123141; --------------------------
……@@ -153,5 +171,6 @@
153171
154172; (load "count-agent.scm")
155173; (obs-txt text-blob)
174; (obs-file "/tmp/demo.txt")
156175; (cog-report-counts)
157176; (cog-get-atoms 'WordNode)