OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-agents commits / 5601e66

Restructure
5601e66da926333596cacf5e53c7c118f061db58
by Linas Vepštas <linasvepstas@gmail.com> · 2024-04-16T22:41:32.000Z

Changed files (1) +17 -20

scm/pair-agent/count-agent.scm +17 -20
……@@ -44,35 +44,32 @@
4444; The Filter matches this, so that (Variable "$x") is equated with the
4545; list of Edges.
4646;
47; XXX Major design flaw, still needs work: the PhraseLink is placed in
48; the main AtomSpace. Thus, it accumulates there, plus also all of the
49; other Links that wrap it, including LgParseBinds, Rule, Filter etc.
50; Nuking the PhraseLink also nukes those, so lots of churn. Alternative
51; is to pass PhraseLink as a value, but then have threading issues...
52; ugh. let me think a moment.
53;
5447(define (obs-txt PLAIN-TEXT)
5548
49 ; Increment the count on one edge.
5650 (define (incr-cnt edge)
5751 (SetValue edge (Predicate "count")
5852 (Plus (Number 0 0 1)
5953 (FloatValueOf edge (Predicate "count") (FloatValueOf (Number 0 0 0))))))
6054
61 (define (extract stuff)
55 ; Given a list (an Atomese LinkValue list) of parse results,
56 ; extract the edges and increment the count on them.
57 (define (count-edges parsed-stuff)
6258 (Filter
6359 (Rule
64 (Variable "$edge")
65 ; (TypedVariable (Variable "$edge") (Type 'Edge))
60 ; (Variable "$edge")
61 (TypedVariable (Variable "$edge") (Type 'Edge))
6662 (Variable "$edge")
6763 (incr-cnt (Variable "$edge")))
68 stuff))
64 parsed-stuff))
6965
66 ; Parse text in a private space.
7067 (define (parseli phrali)
7168 (PureExecLink (LgParseBonds phrali DICT NUML)))
7269
73 (define phrali (Phrase PLAIN-TEXT))
74
75 (define filty
70 ; Given an Atom `phrali` hold text to be parsed, get that text,
71 ; parse it, and increment the counts on the edges.
72 (define (filty phrali)
7673 (Filter
7774 (Rule
7875 ; Type decl
……@@ -85,15 +82,15 @@
8582 (Type 'LinkValue) ; edge-list wrapper
8683 (Glob "$x"))) ; all of the edges
8784 ; Rewrite
88 (extract (Glob "$x"))
85 (count-edges (Glob "$x"))
8986 )
90 (parseli (phrali))))
87 (parseli phrali)))
9188
92 (define parses (cog-execute! filty))
89 (define phrali (Phrase PLAIN-TEXT))
90 (cog-execute! (filty phrali))
9391
94 ; Remove the phrase-link, too.
92 ; Remove the phrase-link, return the list of edges.
9593 (cog-extract-recursive! phrali)
96 parses
9794)
9895
9996; Parses arrive as LinkValues. We want to apply a function to each.
……@@ -123,7 +120,7 @@
123120(define txt-stream-gen
124121 (ValueOf (Concept "foo") (Predicate "some place")))
125122
126(cog-execute! (LgParseBonds txt-stream-gen DICT NUML))
123; (cog-execute! (LgParseBonds txt-stream-gen DICT NUML))
127124
128125; (load "count-agent.scm")
129126; (obs-txt text-blob)