Scoring
:Score(Weight)
This command is optional.
Each expression in a rule variable can contain an optional scoring weight. The scoring weight is specified by appending :Score(Weight)
, where weight is a whole number between 0 and 100, to the end of the expression. The Scoring command can precede an OR operator (|) or the end-of-variable character (;). If an expression does not have an explicit scoring command, a weight value of 100 will be presumed. In this case, the parsing score will be 0 or 100. If a rule variable contains other rule variables, its score value is averaged with the subordinate rules. For example, given the rule variable:
<root> = <a> <b> <c>;
<a> = 'a':Score (100);
<b> = 'b':Score (50);
<c> = 'c':Score (100);
the score for <root>
is calculated as 83 [(100+50+100)/3]. When calculating an average, the score is rounded to the nearest whole number.
The total average score is output in the ParserScore field. The value of ParserScore will be between 0 and 100, as defined in the parsing grammar. 0 is returned when no matches are returned.
The scoring weight of parent expressions can affect the scoring weight of child expressions. For example, rule <C> that can be referenced by rule <A> and <B> as follows:
<A> = <C>;
<B> = <C>:Score(50);
<C> = @Table("something"):Score(50);
If <A>
is matched, it has a score of 100% (the default score) of the value of <C>
, resulting in a scoring weight of 50. But, if <B>
is matched, it has 50% of the value of <C>
, resulting in a scoring weight of 25.
To use this command:
- Position the cursor where you want the command inserted.
- Double-click :Score in the Commands list.
- Type a value between 0 and 100 in the text box.
- Click OK.