WITH
- Last Updated: May 13, 2026
- 2 minute read
- Semaphore
- Documentation
The WITH rule identifies an occurrence of two or more elements in the same field. A field could be a whole document or the title or some other structure.
The score is dependent on the minimum distance between the elements. A distance bands table containing 101 values is associated to the 0-100 weight range as illustrated below. For example a WITH rule with two elements distant by 28 words will score 92. It also implies that elements that are further than 843 positions apart will not lead to any score.
NB it is always the minimum distance used so if several children are used the calculation will use whichever 2 are closest together in the document
| Weight | 100 | 99 | 98 | 97 | 96 | 95 | 94 | 93 | 92 | 91 |
|---|---|---|---|---|---|---|---|---|---|---|
| Distance | 0 | 2 | 5 | 7 | 8 | 11 | 14 | 22 | 27 | 29 |
| Weight | 90 | 89 | 88 | 87 | 86 | 85 | 84 | 93 | 82 | 81 |
| Distance | 36 | 39 | 42 | 45 | 50 | 55 | 58 | 62 | 66 | 70 |
| Weight | 80 | 79 | 78 | 77 | 76 | 75 | 74 | 73 | 72 | 71 |
| Distance | 72 | 75 | 77 | 82 | 85 | 88 | 90 | 95 | 98 | 101 |
| Weight | 70 | 69 | 68 | 67 | 66 | 65 | 64 | 63 | 62 | 61 |
| Distance | 105 | 107 | 110 | 115 | 118 | 120 | 123 | 127 | 130 | 135 |
| Weight | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 |
| Distance | 138 | 141 | 145 | 149 | 152 | 155 | 160 | 162 | 167 | 173 |
| Weight | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 |
| Distance | 175 | 180 | 185 | 190 | 195 | 200 | 204 | 208 | 210 | 215 |
| Weight | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 | 31 |
| Distance | 220 | 223 | 228 | 233 | 238 | 243 | 250 | 255 | 262 | 270 |
| Weight | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 |
| Distance | 276 | 285 | 295 | 304 | 310 | 320 | 325 | 334 | 341 | 350 |
| Weight | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 |
| Distance | 358 | 365 | 375 | 385 | 400 | 410 | 420 | 429 | 440 | 450 |
| Weight | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
| Distance | 475 | 500 | 525 | 528 | 550 | 581 | 646 | 732 | 793 | 843 |
Since Semaphore 3.5 the DATA attribute is now supported for this rule. The provided text will be parsed and each token found will be appended as a child text rule. This is mainly as a convenience to avoid typing but also avoids issues where the tokenisation is not easily determined for the text
Attributes
- _KEY
- DATA // New from Semaphore version 3.5 on //
- LABEL
- NOT
- SCALE
- WEIGHT - In this case weight is used as a scaling factor - If the resulting score of the children is 50 (0.5) and weight is set to 80 (0.80) the returned score will be (score * weight / 100) or 40 (0.40)
Children
Example
The following rulebase fragment
<with weight="100">
<text data="Jean-Claude Trichet" />
<text data="inflation" />
</with>
Used with the following document body
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.
is separated by 32 words so will fire the rule with a score of “0.90”