Powered by Zoomin Software. For more details please contactZoomin

Semaphore Classification Server Rulebase Reference

The FOREACH rule (Experimental)

  • Last Updated: May 13, 2026
  • 2 minute read
    • Semaphore
    • Documentation

Supports looping over the sink rules individual phrase ranges

Experimental use only - the semantics of this rule may change between versions of CS. Use with care

Score calculation

This rule scores the maximum of any of its iterations.

Evidence calculation

Its evidence is union of the phrase ranges from all its iterations

Attribute information

Children restrictions

First child must be a sink rule otherwise the rule is invalid.
Any rule is allowed after the first child other than those only allowed a specific parent

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="cemetery" />
        </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.

TitleResults for “How to create a CRG?”Also Available inAlert