GlobNode

From OpenCog
Jump to: navigation, search

The GlobNode is a type of VariableNode that can match multiple successive atoms during pattern matching. A normal variable node can only match a single atom. See glob on wikipedia for a definition of globbing.

Example

The pattern immediately below, re-writes "I * you" to "I * you too".

  (BindLink
  (ListLink
     (ConceptNode "I")
     (GlobNode "$star")
     (ConceptNode "you"))
  (ListLink
     (ConceptNode "I")
     (GlobNode "$star")
     (ConceptNode "you")
     (ConceptNode "too")))

When applied to this:

(ListLink
  (ConceptNode "I")
  (ConceptNode "really")
  (ConceptNode "totally")
  (ConceptNode "need")
  (ConceptNode "you"))

it will produce the output

(ListLink
  (ConceptNode "I")
  (ConceptNode "really")
  (ConceptNode "totally")
  (ConceptNode "need")
  (ConceptNode "you")
  (ConceptNode "too"))