The SOURCE rule (Experimental)
- Last Updated: May 13, 2026
- 2 minute read
- Semaphore
- Documentation
Provides the evidence looped over using FOREACH
Experimental use only - the semantics of this rule may change between versions of CS. Use with care
Score calculation
N/A technically is a LINK calculation but will probably be irrelevant in use
Evidence calculation
Each phrase range from the SINKfor the first parent [FOREACH]](../rules/foreach.md)rule will be presented to all the SOURCE rules and the rulenet branch (up to the parent FOREACH) will be evaluated multiple times
Attribute information
- any common attribute
Children restrictions
May not have a child - it will link automatically (so that will be a child) to the SINK rule from the first parent FOREACH rule
Parent restrictions
- must be a direct descendant child of a FOREACH rule otherwise not valid (ie you cannot use a LINK rule to find the approprate parent FOREACH
Description
The source rule defines where the iterated phrase ranges from a SINK rule attached to a direct ascendant FOREACH will be applied. One (or more) SOURCE rules will connect to the sink and the foreach rule will feed the individual phrase range to those source rules and evaluate the branch of the rulenet iteratively.
Example 1
The following rulebase fragment
<foreach extract="1" extract_tags="place" >
<sink>
<text data="Arlington" />
</sink>
<max>
<sentence>
<source tag="Arlington (Texas)" />
<any data="Texas" />
</sentence>
<sentence>
<source tag="Arlington (Virginia)" />
<any data="Texas" />
</sentence>
<sentence weight="80" >
<source tag="Arlington (Texas)" />
<any data="Dallas Cowboys Stadium" />
</sentence>
<sentence weight="80" >
<source tag="Arlington (Virginia)" />
<any data="National Cemetery Washington" />
</sentence>
<source tag="Arlington (Unknown)" weight="70" />
</max>
</foreach>
evaluating the following document text
Across the Potomoc is the National Cemetery in Arlington.
The Dallas Cowboys are investing heavily in new wi-fi infrastruce in their Arlington Stadium.
Arlington House is a significant piece of architectural heritage nestling in a Cotswold valley.
Would extract the three occurences of “Arlington” with the appropriate tag applied to discriminate between the uses.
In this case the foreach rule is used to re-use the max rule - but by iterating over each phrase range in the sink you avoid the global behaviour of the max and allow the decision to be made per phrase range.
...
<META name="place" value="Arlington (Texas)" score="0.80"/>
<META name="place" value="Arlington (Unknown)" score="0.80"/>
<META name="place" value="Arlington (Virginia)" score="0.80"/>
...
NB the score for each iteration of the foreach is not kept - ie even though the score for the max for the 3rd Arlington (the one in “Arlington House”) would be 0.70 and the phrase range tagged “Arlington (Unknown)” the tagged phrase range is kept and ends up as tagged evidence for the foreach rule but the score from that iteration is discarded. The score for the foreach will currently be the max of any iterations score.