OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-generate commits / 4282591

Add a connector-mating example
4282591749ee80665084ee46f84f1675eb6883e2
by Linas Vepstas <linasvepstas@gmail.com> · 2021-12-04T03:24:53.000Z

Changed files (2) +75 -0

examples/README.md +7 -0
……@@ -42,4 +42,11 @@ also serve to constrain the parse itself.)
4242 The demo itself, employing the above dictionaries to generate a
4343 (small) corpus of sentences.
4444
45Some general comments about the mating rules for connectors are given below:
46
47* [trisexual](trisexual.scm) --
48 Examples of mono-sexual, heterosexual and tri-sexual mating rules.
49 Plus a short explanation of why this is called "sexuality"; other
50 code calls this "polarity" (so, mono-polar, bipolar and tri-polar).
51
4552That's all for now!
examples/trisexual.scm +68 -0
……@@ -0,0 +1,68 @@
1;
2; trisexual.scm
3;
4; This demo provides a very short discussion of how connector directions
5; can be specified. Three examples are given: mono-sexual, heterosexual
6; and tri-sexual. The word "sexual" is used because of the obvious
7; (hetero) "sexuality" of real-world cardboard jigsaw puzzle connectors.
8;
9; Other parts of the code call this "polarity", and so the three examples
10; could be called mono-polar, bipolar and tri-polar. The concept of "mating"
11; applies for either vocabulary.
12;
13(use-modules (opencog))
14;
15; --------------------------------------
16; The mono-sexual example occurs in the `basic-network.scm` example.
17; Please review that example. The relevant section is cut-n-pasted
18; below:
19;
20; Define the connectable directions (poles). In this case, the
21; connectors are all the same, and the direction (or "pole")
22; connects to itself (rather than having opposite polarity).
23; Furthermore, the connections are symmetric (creating undirected
24; edges.) Thus, the pole-pair set is very simple.
25(define polarity-set (Concept "any to any"))
26(Member (Set (ConnectorDir "*") (ConnectorDir "*")) polarity-set)
27
28; --------------------------------------
29; The hetero-sexual example occurs in the `dict-*.scm` examples, and is
30; given in the file `grammar.scm` near the middle. The relevant section
31; is cut-n-pasted below:
32;
33; Define the connectable directions (poles). In this case, there
34; are two direction types: "+" and "-" denoting "to the right" and
35; "to the left". The connector mating rules are that "+" can connect
36; only to "-", and vice-versa. The resulting edges are NOT directed
37; edges -- they are still undirected edges; the poles are only used
38; to indicate word-order in the generated sentence. This convention of
39; plus and minus for word-order is in keeping with the representation
40; used in the Link Grammar parser. The notation used here should look
41; very familiar, when compared to the notaton there. This is not
42; accidental.
43;
44; All of the example dictionaries use this same set of direction rules.
45; Its very simple: only "+" and "-" connections are allowed.
46;
47(define dir-set (Concept "left-right connectors"))
48(Member (Set (ConnectorDir "+") (ConnectorDir "-")) dir-set)
49
50; --------------------------------------
51; The tri-sexual example follows below. It is not currently used in any
52; demos; the reader is encouraged to construct one.
53;
54; The example here is that there are three sexes, `a`, `b` and `c`. The
55; mating rules are such that sex `a` can mate with `b`, but nothing else
56; so `a` cannot mate to other `a`'s nor to `c`. The sex `c` can also mate
57; to `b`, but not to itself. Finally, `b` cannot mate with itself. This
58; idea is encoded in the following rules:
59
60(define sexuality-set (Concept "abc example"))
61(Member (Set (ConnectorDir "a") (ConnectorDir "b")) sexuality-set)
62(Member (Set (ConnectorDir "c") (ConnectorDir "b")) sexuality-set)
63
64; --------------------------------------
65; All three examples above are quite simple; fairly general mating rules
66; can be encoded following the above pattern.
67;
68; That's all, folks!