OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-agents commits / 7b57d16

Misc bug-fixes
7b57d16a4d8702503255074b4792b6b6b1a956f3
by Linas Vepštas <linasvepstas@gmail.com> · 2024-05-03T14:17:51.000Z

Changed files (2) +24 -8

examples/pair-count.scm +9 -2
……@@ -14,9 +14,9 @@
1414; The steps proceed as follows:
1515; 1) Example of using the Link Grammar parser to generate word-pairs.
1616; 2) A debug printing utility.
17; 3) Using filters to extract subelements of a data stream.
17; 3) Using filters to extract sub-elements of a data stream.
1818; 4) Using filters to increment counts on elements of a data stream.
19; 5) Reading text from a file.
19; 5) Reading text from a file, and running it through the pipe.
2020;
2121(use-modules (opencog) (opencog exec) (opencog persist))
2222(use-modules (opencog nlp) (opencog nlp lg-parse))
……@@ -284,6 +284,13 @@
284284; That's it. Now wire it all together:
285285(cog-execute! (edge-filter parse-stream edge-counter))
286286
287; If end-of-file is hit while experimenting, rest to the begining,
288; be re-opening the file:
289(cog-execute!
290 (SetValue (Anchor "pipe demo") (Predicate "text src")
291 (Open (Type 'TextFileStream)
292 (Sensory "file:///tmp/demo.txt"))))
293
287294; Note the actual flow is different from the how this is written, above.
288295; First, the parse stream flows to the edge-filter, and then the
289296; edge-counter runs. Some twiddling about in scheme could straighten
scm/pair-agent/count-agent.scm +15 -6
……@@ -83,15 +83,13 @@
8383 (FUNKY (Variable "$edge-list")))
8484 PASRC))
8585
86 ; Parse text in a private space.
87 (define (priv-parse TXT-SRC)
88 (PureExecLink (LgParseBonds TXT-SRC DICT NUML)))
86 (define parser (LgParseBonds txt-stream DICT NUML))
8987
90 ; I dunno. Is private parsing needed?
91 (define (regular-parse TXT-SRC) (LgParseBonds TXT-SRC DICT NUML))
88 ; Is there any benefit to private parsing?
89 ; (edge-filter (PureExecLink parser) edge-counter)
9290
9391 ; Return the parser.
94 (edge-filter edge-counter (regular-parse txt-stream))
92 (edge-filter parser edge-counter)
9593)
9694
9795; --------------------------------------------------------------
……@@ -123,3 +121,14 @@
123121)
124122
125123; --------------------------
124; Run the above demo:
125; (obs-file "/tmp/demo.txt")
126;
127; Look at results
128; (cog-report-counts)
129; (cog-execute! (ValueOf (Word "is") (Predicate "count")))
130;
131; Erase all words, so we can try again.
132; (extract-type 'WordNode)
133
134; --------------------------