IF
- Last Updated: May 13, 2026
- 2 minute read
- Semaphore
- Documentation
The IF operator allows a conditional scoring to be written.
It may only have 2 or 3 children:
- The first child must be a CONDITON
- The second child must be a THEN
- The optional 3rd child must be an ELSE if it exists
The IF rule will have the score and the evidence of the THEN child if the condition rule is fired.
If the CONDITION rule is not fired then the IF rule will score 0 or have the value of the ELSE child if present.
Score calculation
Score is the score of the <then> rule if condition is fired or else is the <else> rule score if existing
Evidence calculation
The evidence is the evidence of the <then> rule if the condition is fired otherwise is the evidence of the <else> rule.
Attribute information
- any attribute
Children restrictions
// Note: It is an error to have any other children rules//
Example
The following rulebase fragment
<if>
<condition>
<all>
<text data="Trichet"/>
<text data="Bob" not="1"/>
</all>
</condition>
<then>
<combine>
<text data="Trichet" weight="10" foreach="1" />
<text data="Bob" not="1" weight="10"/>
</combine>
</then>
</if>
evaluated against the following document
Jean-Claude Trichet announced today a rise of 1/2 point in interest rates.
In a separate intervention the governor of the European Central Bank announced that the
institution will keep a firm handle on inflation.]]></body>
Would score 0.19 (the combined value of 10,10)
NB this particular construction has arisen often so the ALL_COMBINE rule has been added to do exactly the above behaviour with far fewer rules
<all_combine>
<text data="Trichet" weight="10" foreach="1" />
<text data="Bob" not="1" weight="10"/>
</all_combine>
However the if rule provides more flexibility