Pattern-Based Search

Two Great Features in 4.5
June 19, 2017
LISP Scripting Engine
June 19, 2017

Let us say that you wish to find out which of your clients have Venus as their 7th cuspal sublord and Venus being in its own sub. Here is a pattern to search for:

(cusp (number 7) (sublord Venus))

(planet (name Venus) (sublord Venus))

KPAstro 4.1 has an amazing feature called Patterns. It allows you to perform sophisticated searches. There are 3 possible usage scenarios:

1) To check whether the currently active chart satisfies a pattern
2) From the database of client charts, find out which satisfy a pattern
3) In chart Animation mode, identify the time points when a pattern is satisfied

Let us consider case (2). Wouldn’t it be nice if we can scan the client records to identify certain chart patterns? Consider a simple case: Which clients have their lagna falling in a fire sign? Isn’t it tedious to open one chart after another and check this condition manually? With the newly introduced patterns feature, it is quite easy to do this. Here is the pattern definition:

(rasi-info (element fire) (seqid ?id))
(cusp (number 1) (sign ?id)))

The above pattern has two pattern elements (PEs), joined by and. This means both the conditions must be satisfied for the whole pattern to be considered satisfied. The first pattern element says that there exists a sign, whose sequence number (sign number 1 to 12) we want to find out, and which is of fire element. The question mark followed by a name is called a Pattern Variable. The pattern engine will bind a value for it when it encounters a matching context. The second PE says we are looking for cusp number 1 (that is, lagna) falling in the same sign satisfied by the first PE. Taken together, these mean that the first cusp must fall in a fire sign.

When you run this pattern over the records in the database (this can take a while depending on the number of records), KPAstro will show the matching records, if any.

Let us look at another pattern. Suppose we want to identify those charts where the 7th cuspal sublord is in its own sign, star and sub. Here is the pattern:

(cusp (number 7) (sublord ?csl))
(planet (name ?csl) (signlord ?csl) (starlord ?csl) (sublord ?csl)))

Let us understand this pattern. As in the earlier example, this pattern consists of 2 PEs. The first one will match the sublord of the 7th cusp. The matching planet’s name will be bound to the variable ?csl. The second PE requires that the planet that matches the 7th cuspal sublord must also be the same as its signlord, starlord and sublord.

Let us take a more complicated example. Planetary Geometry is an interesting area to study. If two planets are 120 degrees apart, it is called a Trine. Suppose we have 3 planets in a chart that are 120 degrees away from each other, it is called a Grand Trine. In addition, if there is a fourth planet in opposition (180 degrees away) to any of these 3 planets, then such a planetary configuration is called a Kite. Now, how can you identify those clients of yours whose chart has this pattern? Can you even imagine doing this pattern scan manually? Here is the pattern definition in KPAstro:

(p-aspect (planet1 ?p1) (planet2 ?p2) (nameis Trine))
(p-aspect (planet1 ?p2) (planet2 ?p3) (nameis Trine))
(p-aspect (planet1 ?p1) (planet2 ?p3) (nameis Trine))
(p-aspect (planet1 ?p4) (planet2 ?p1) (nameis Opposition))
(p-aspect (planet1 ?p4) (planet2 ?p2) (nameis Opposition))
(p-aspect (planet1 ?p4) (planet2 ?p3) (nameis Opposition)))
(test (distinct Fortuna ?p1 ?p2 ?p3 ?p4)))

This pattern has Or as well as And conditions. First, we identify three planets located in Trine configuration from each other. Next we look for a planet in opposition to any of the three planets. Naturally, this involves Or. Finally, we have a an additional test element. It imposes extra condition on the matching variables. In this example, we are looking for 4 planets that are all different and none of them is Fortuna (we do not treat Fortuna as a planet).

Quite elegant, don’t you think? 

What is even more interesting is that you can apply the same idea of pattern-based searching to identify when a particular even may occur! KPAstro’s Chart Animation feature now allows you to apply a pattern to its animation. As the animation engine progresses through time, it applies the pattern at each time point. If the pattern matches that particular chart configuration, the animation engine accumulates that information. This is much more powerful than the Transit Lookup feature.

It may be of interest to know that this feature was introduced in KPAstro version 2.0 itself, but it was used internally by our team without making it public. Based on feedback from a group of trusted astrologer friends, we have now decided to make it available to everyone  (this is an optional feature and is not part of the Basic version).

Leave a Reply
