FIELD
- Last Updated: May 13, 2026
- 3 minute read
- Semaphore
- Documentation
The Field rule filters evidence from its children and fires with its weight as a score if any of the children have evidence within the specified field. It is typically used to reduce the number of rules in a rulebase since it’s behaviour may be implemented (and slightly more efficiently) using the field attribute.
Score calculation
Scores its given weight if any child evidence is within the given field
Evidence calculation
The child evidence which is within the given field.
Attribute information
Children restrictions
(No reason for any restriction but normally one of)
Example
The following rulebase fragment
<field weight="20" foreach="1" data="title" >
<phrase>
<text data="A" />
<text data="B" />
</phrase>
</field>
has the same result as
<phrase field="title" foreach="1" weight="20">
<text data="A" />
<text data="B" />
</phrase>
And will find the phrase “A B” if it occurs in the title field (and score 20 for each occurrence of the phrase in this field)
A fair question would be “how does this save rules?” - since it appears to add an extra rule to do the same job (and theoretically less efficiently though haven’t been able to measure this)
Consider the following rulebase fragment
<intersection label="sentence" >
<sentence data="A B" use_zone_as_evidence="1" />
<sentence not="1" use_zone_as_evidence="1" data="A B C" />
</intersection>
<intersection label="near" >
<near data="A B" count="2" />
<near not="1" count="2" data="A B C" />
</intersection>
<intersection label="phrase" >
<phrase data="A B" />
<phrase not="1" data="A B C" />
</intersection>
Which is a simplified example of rules with preclusion generated by some publishing templates.
By using these label’s and the new field rule we can reduce the size of a rulenet dramatically
<combine>
<link label="sentence" weight="10" foreach="1" />
<link label="near" weight="10" foreach="1" />
<link label="phrase" weight="10" foreach="1" />
<field data="title" weight="10" foreach="1" >
<link label="sentence" />
<link label="near" />
<link label="phrase" />
</field>
<with weight="20">
<text field="body" data="{field_start}" />
<field data="body" >
<link label="sentence" />
<link label="near" />
<link label="phrase" />
</field>
</with>
</combine>
Which is an example of the style known as “additive scoring” which instead of using complex max rules to select the highest scoring evidence builds the scores from the component parts.
Here we have a base level score of 10 for each sentence containing both “A” and “B” (but without “C”). Since a near group is also by default within a sentence if we have “B something A” then we will add 10 and so effectively score 20 for each near group in the document. Again a phrase “A B” is also a near group so we score approximately 30 for each phrase “A B” (excluding “A B C”) in the document.
We than boost the score by a further 10 for each occurrence of the phrase,near or sentence in the title field (note we aren’t discriminating here between phrase or sentence for this boost but we could easily if required - however since our base score is already taking into account whether its a phrase or sentence it is probably sufficient just to boost if any of the constructs occur in the title.
Again we boost if the phrase,near or sentence “A B” occurs to the start of the body - this will pick the earliest such evidence in the document and will use the normal with distance scoring method which is then reduced to the range [0,20].
Just for an example of this - if we had a document which has a title
Our title contains B and A.
with a body like:
A B is at the start of this document. In the next sentence we have A B C in it. In the third sentence we have B and after quite a few words A.
This will score
| type | weight | num occurrences | score |
|---|---|---|---|
| sentence | 10 | 3 | 27 |
| near | 10 | 2 | 19 |
| phrase | 10 | 1 | 10 |
| title | 10 | 2 | 19 |
| with | 20 | 1 | 20 |
which when combined scores 66.
This rule was introduced in Semaphore 3.7