| … | … | @@ -9,7 +9,7 @@ |
| 9 | 9 | ; This source blocks if there's nothing to be read; else it |
| 10 | 10 | ; returns the next PhraseNode. The SRFI's call this a generator. |
| 11 | 11 | ; For now, see `sensory.scm` module and example. |
| 12 | | ; It uses a FileReadNode to loop voer a text file. |
| 12 | ; It uses a FileReadNode to loop over a text file. |
| 13 | 13 | ; 2) (Optional) Some way to split one source into multiple sources. |
| 14 | 14 | ; Maybe this: |
| 15 | 15 | ; https://wiki.opencog.org/w/PromiseLink#Multiplex_Example |
| … | … | @@ -29,7 +29,7 @@ |
| 29 | 29 | ; The below demos this design. |
| 30 | 30 | ; |
| 31 | 31 | ; Open issues: |
| 32 | | ; *) Need to call cog-execute! in a loop to loop over whole file. |
| 32 | ; *) Need to call cog-execute! in a loop, to loop over whole file. |
| 33 | 33 | ; Would be nicer to not have to do this. |
| 34 | 34 | ; *) End-of-file results in a throw from parser. This is a side |
| 35 | 35 | ; effect. We need some proper end-of-file handling. |
| … | … | @@ -137,15 +137,11 @@ |
| 137 | 137 | (define txt-stream (ValueOf (Concept "foo") (Predicate "some place"))) |
| 138 | 138 | (define parser (make-parser txt-stream)) |
| 139 | 139 | |
| 140 | | (define phrali (FileRead (string-append "file://" FILE-NAME))) |
| 140 | (define phrali (Open (Type 'TextFileStream) |
| 141 | (Sensory (string-append "file://" FILE-NAME)))) |
| 141 | 142 | |
| 142 | | ; This will do the trick to set the value. Except it creates an Atom |
| 143 | | ; (cog-execute! |
| 144 | | ; (SetValue (Concept "foo") (Predicate "some place") |
| 145 | | ; (FileRead "file:///tmp/demo.txt"))) |
| 146 | | ; Same as bove, without creating Atom. |
| 147 | | (cog-set-value! (Concept "foo") (Predicate "some place") |
| 148 | | (cog-execute! phrali)) |
| 143 | (cog-execute! |
| 144 | (SetValue (Concept "foo") (Predicate "some place") phrali)) |
| 149 | 145 | |
| 150 | 146 | ; Parse only first line of file: |
| 151 | 147 | ; (cog-execute! parser) |