OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-agents commits / f9b5a20

Continue with the demo
f9b5a209efd6c2cf0f389b05d59bd969879d5ba0
by Linas Vepštas <linasvepstas@gmail.com> · 2024-05-02T19:05:39.000Z

Changed files (1) +44 -0

examples/pair-count.scm +44 -0
……@@ -16,6 +16,50 @@
1616(use-modules (opencog sensory))
1717(use-modules (srfi srfi-1))
1818
19; --------------------------------------------------------------
20; The Link Grammar "any" dictionary will parse a text string using
21; a uniformly-dsitributed random planar graph. That is, it will
22; generate random word-pair links, arranged so that no edges intersect.
23; Lets try it.
24
25(cog-execute!
26 (LgParseBonds (Phrase "this is a test") (LgDict "any") (Number 1)))
27
28; The `(Number 1)` says that only one parse is wanted.
29; Note how a bunch of Edges flew by; these specify the word pairs.
30; Note how the list of edges is wrapped by a `LinkValue`.
31; Note how a list of words is generated, before the edges; it is also
32; wrapped in a LinkValue. The graph, as a whole, consisting of a list of
33; vertexes (the words) and edges, is wrapped in a LinkValue.
34
35; View the contents of the AtomSpace:
36(cog-report-counts)
37
38; View the list of words in the AtomSpace:
39(cog-get-atoms 'WordNode)
40
41; Remove the words and edges:
42(for-each cog-extract-recursive! (cog-get-atoms 'WordNode))
43
44; Equivalently:
45(extract-type 'WordNode)
46
47; The only reason to remove is to start with a clean slate, as the demo
48; progresses. Otherwise, it's OK to let things stay as they are.
49; Assorted cruft will build up in the AtomSpace as the demo progresses,
50; that cruft might be confusing.
51
52; --------------------------------------------------------------
53; Next ...
54
55; --------------------------------------------------------------
56; This demo starts where the `file-read.scm` demo in the sensory
57; project leaves off. See
58; https://github.com/opencog/sensory/raw/master/examples/file-read.scm
59
60
61
62
1963; --------------------------------------------------------------
2064; Return a text parser that counts edges on a stream. The
2165; `txt-stream` must be an Atom that can serve as a source of text.