AnchorNode

From OpenCog
Jump to: navigation, search

The AnchorNode is a Node type useful for marking well-known locations in Atomese code. It is usually used to mark a location where something can be found. it provides a very simple mechanism to put things in the AtomSpace where other processing threads can find them. So, if you have "SomeAtoms" and don't want to loose track of them, you create the following:

ListLink
    AnchorNode "my-stuff"
    SomeAtoms

Then as long as you can remember that your stuff is called "my-stuff", you just have to look at the incoming set for the AnchorNode, which finds the ListLink, which links your stuff.

Example: Anchor for newly parsed sentences

One example can be found in the sentence representation subsystem of the natural language processing pipeline:

(ListLink
   (AnchorNode "# New Parsed Sentence")
   (SentenceNode "sentence@2d19c7e7-2e02-4d5e-9cbe-6772174f3f4d")
)

Thus, processing threads in charge of dealing with recently input text can scan for links to this particular AnchorNode (it will always have the name "# New Parsed Sentence").

Example: StateLinks

(use-modules (opencog) (opencog exec))

; Define some state in Atomese.
(State (Anchor "the answer") (Number 42))