SCALE
- Last Updated: May 13, 2026
- 2 minute read
- Semaphore
- Documentation
Scales the score according to the number of words in all the phrase ranges attached to the rule
Applies to
Note rules marked with * apply the scale to the calculated score - those without just use the weight as the rules score (provided that children pass the appropriate test where applicable)
Does Not apply to
Values
- “1” - Do scale
- “0” - Don’t scale (default)
Algorithm
Calculate the story density - This is the ( ( number of words found by the rule ) * 10000) / ( number of words in document )
Calculate the percentage change based on the following table:
| story density | 5 | 6 | 14 | 17 | 19 | 23 | 25 | 29 | 33 | 36 | 41 | 45 | 51 | 56 | 65 | 71 | 83 | 93 | 109 | 126 | 169 |
| percentage | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
i.e. if story density was 1 then the percentage would be 80% - if story density was 100 percentage would be 98%
Then the existing weight for the rule is adjusted by this percentage (if no weight attribute is present for the rule this will be 100)
Example
If we had a rulebase like :
<any scale="1">
<text data="simple"/>
<text data="example"/>
</any>
and applied it to a simple document
This is a simple example document to demonstrate the scale attribute.
We would have:
Number of words found by any rule = 2
Number of words in document = 11
Story density = 1818
Percentage = 100%
Resulting weight = 100
Since this is an any rule we are applied to this ignores the child scores and resulting score of rule would be 100
with a weight applied to the any rule we would have:
<any scale="1" weight="50" >
<text data="simple"/>
<text data="example"/>
</any>
If our example document had 2,500 words but still only 1 occurrence of simple and 1 occurrence of example then we would have:
Number of words found by rule = 2
Number of words in document = 2,500
Story density = 8
Percentage= 81
Resulting weight = 42
Again this would be the resulting score for an any rule (for other rules this may be weight * (child scores))