Fix wording with @nlg
L4 never rewrites your words, so a rule can read badly in a rendered document. This page shows the fix for each problem.
Before you start: Make rules read like law.
Examples:
-- Rules that render badly. fix-wording-after.l4 is the same file with the fixes.
IMPORT daydate
DECLARE Employee
HAS `the start date` IS A NUMBER
`I am or have been married` IS A BOOLEAN
`a member of a pension scheme` IS A BOOLEAN
`the section engaged` IS A NUMBER
`is on leave` IS A BOOLEAN
ASSUME `is aged 16 or over` IS A FUNCTION FROM Employee TO BOOLEAN
GIVEN `the employee` IS AN Employee
GIVETH A BOOLEAN
`is authorised` MEANS `the employee`'s `the start date` AT LEAST 1
GIVEN `the section` IS A NUMBER
GIVETH A BOOLEAN
`is one of sections 9 to 14` MEANS
`the section` AT LEAST 9 AND `the section` AT MOST 14
GIVEN `the employee` IS AN Employee
GIVETH A BOOLEAN
`may opt out` MEANS
`is authorised` `the employee`
AND `is aged 16 or over` `the employee`
AND NOT `the employee`'s `I am or have been married`
AND NOT `the employee`'s `a member of a pension scheme`
AND NOT `the employee`'s `is on leave`
AND NOT (`is one of sections 9 to 14` (`the employee`'s `the section engaged`) AND `is authorised` `the employee`)
GIVEN last IS A DATE, next IS A DATE, agrees IS A BOOLEAN
GIVETH A BOOLEAN
DECIDE `the change is at least 92 days after the last, last` last `, next` next `, employer agrees:` agrees IF
agrees OR Day next MINUS Day last AT LEAST 92
and
-- The rules of fix-wording-before.l4, with their wording fixed.
IMPORT daydate
DECLARE Employee
HAS `the start date` IS A NUMBER
@nlg start date
`I am or have been married` IS A BOOLEAN
@nlg the employee is or has been married
`a member of a pension scheme` IS A BOOLEAN
@nlg the employee is a member of a pension scheme
`the section engaged` IS A NUMBER
@nlg section engaged
`is aged 16 or over` IS A BOOLEAN
`is on leave` IS A BOOLEAN
GIVEN `the employee` IS AN Employee
GIVETH A BOOLEAN
@nlg %`the employee`% is authorised
`is authorised` MEANS `the employee`'s `the start date` AT LEAST 1
GIVEN `the section` IS A NUMBER
GIVETH A BOOLEAN
@nlg %`the section`% is one of sections 9 to 14
`is one of sections 9 to 14` MEANS
`the section` AT LEAST 9 AND `the section` AT MOST 14
GIVEN `the employee` IS AN Employee
GIVETH A BOOLEAN
@nlg %`the employee`% is not on leave
`is at work` MEANS NOT `the employee`'s `is on leave`
GIVEN `the employee` IS AN Employee
GIVETH A BOOLEAN
`may opt out` MEANS
`is authorised` `the employee`
AND `the employee`'s `is aged 16 or over`
AND NOT `the employee`'s `I am or have been married`
AND NOT `the employee`'s `a member of a pension scheme`
AND `is at work` `the employee`
AND NOT (`is one of sections 9 to 14` (`the employee`'s `the section engaged`) AND `is authorised` `the employee`)
GIVEN `the last change` IS A DATE, `the next change` IS A DATE, `the employer agrees` IS A BOOLEAN
GIVETH A BOOLEAN
@nlg %`the next change`% is at least 92 days after %`the last change`%, or %`the employer agrees`%
DECIDE `the change is far enough apart` `the last change` `the next change` `the employer agrees` IF
`the employer agrees` OR Day `the next change` MINUS Day `the last change` AT LEAST 92
. See each one with l4 render fix-wording-before.l4 --format text.
| You see | Fix |
|---|---|
is authorised for the employee |
Give the rule a subject |
it is not the case that both is one of sections 9 to 14 |
Give the rule a subject |
…, for the employee |
Write a field as a statement |
the employee's the start date |
Drop the extra "the" |
is aged 16 or over with the employee |
Make an assumed fact a field |
after the last, last [last], next [next] |
Write a sentence for the heading |
it is not the case that the employee is on leave |
Write the negative yourself |
Give the rule a subject
A rule with no sentence reads as its name, then its inputs:
(a) is authorised for the employee;
(f) it is not the case that both is one of sections 9 to 14 for the employee's the section engaged and …
Write a sentence, with a slot for each input:
GIVEN `the employee` IS AN Employee
GIVETH A BOOLEAN
@nlg %`the employee`% is authorised
`is authorised` MEANS `the employee`'s `the start date` AT LEAST 1
(a) the employee is authorised;
(f) it is not the case that both the employee's section engaged is one of sections 9 to 14 and …
Write a field as a statement
A BOOLEAN field that doesn't start with is or has reads as its own words, then says whose it is:
(c) it is not the case that I am or have been married, for the employee;
(d) it is not the case that a member of a pension scheme, for the employee;
Give the field a whole statement. It then reads alone:
`I am or have been married` IS A BOOLEAN
@nlg the employee is or has been married
`a member of a pension scheme` IS A BOOLEAN
@nlg the employee is a member of a pension scheme
(c) it is not the case that the employee is or has been married;
(d) it is not the case that the employee is a member of a pension scheme;
Drop the extra "the"
Any other field reads after its owner, so a name that starts with "the" doubles up:
the employee's the start date
Give the field the words that follow the owner:
`the start date` IS A NUMBER
@nlg start date
the employee's start date
Make an assumed fact a field
An ASSUMEd function has no named inputs, so a sentence has no slot to fill:
ASSUME `is aged 16 or over` IS A FUNCTION FROM Employee TO BOOLEAN
(b) is aged 16 or over with the employee;
Make it a BOOLEAN field. A field that starts with is or has follows its owner, so it needs no @nlg:
DECLARE Employee
HAS `is aged 16 or over` IS A BOOLEAN
(b) the employee is aged 16 or over;
Write a sentence for the heading
A mixfix rule reads as its pattern, with its inputs as blanks. Punctuation in the pattern reads as written:
The change is at least 92 days after the last, last [last], next [next], employer agrees: [agrees] if:
Write a sentence, and name the inputs as nouns:
GIVEN `the last change` IS A DATE, `the next change` IS A DATE, `the employer agrees` IS A BOOLEAN
GIVETH A BOOLEAN
@nlg %`the next change`% is at least 92 days after %`the last change`%, or %`the employer agrees`%
[the next change] is at least 92 days after [the last change], or [the employer agrees] if:
Write the negative yourself
NOT stays outside the statement it denies:
(e) it is not the case that the employee is on leave; and
For a negative wording, write a rule with a sentence, and call it:
GIVEN `the employee` IS AN Employee
GIVETH A BOOLEAN
@nlg %`the employee`% is not on leave
`is at work` MEANS NOT `the employee`'s `is on leave`
(e) the employee is not on leave; and
Check the sentence
@nlg changes the wording, not the logic, and L4 can't tell if a sentence is true.
Read each sentence against its rule, and try names first: a better name needs no sentence.
For the exact rules, see @nlg.