Some Example Text Planning Rules from DIOGENES-90

(These are used to map TAMERLAN meaning representations
 to text structure frames)

CAUSAL RELATIONS

Rules 1, 2, 3 and 4 all relate to the causal relation.  The first argument
of such a relation corresponds to the causing event or action, the second
to the resulting action or state.

Rule 1 applies when the producer is interested in the state resulting from
the causal action.  Rules 2, 3 and 4 apply when the producer focusses on
the agent of the result action and when besides both the causal and the
resulting actions have the same agent.  Rules 2, 3 and 4 differ only in the
values the pragmatic factors must assume for the conditions to be
fullfilled.

The right hand sides of all four rules decide on a) the number and type of
output sentences; b) the order and dependency relations between clauses; c)
cohesion markers; and d) whether the agent of the result action should be
omitted for the resulting state to become the subject matter (and, later,
syntactically the subject) of the sentence (Rule 1).

(planner-rule Rule-1

IF (and (= @relation_i.type domain-causal-enablement)
        (= @relation_i.arguments^first @clause_j.proposition)
        (= @relation_i.arguments^second @clause_k.proposition)
        (= @clause_k.topic @clause_k.proposition.theme))

THEN (let* ((clause-unit-k (instantiate-unit 'plan-clause-unit))
            (clause-unit-j (instantiate-unit 'plan-clause-unit))
            (sentence-unit 
              (instantiate-unit 'plan-sentence-unit
                `((type sentence)(subtype complex)
                  (clauses ,clause-unit-k ,clause-unit-j)))))
       (add-unit-filler sentence-unit 'id sentence-unit)
       (add-unit-filler clause-unit-k 'input-frame @clause_k)
       (add-unit-filler clause-unit-k 'dependent-clause clause-unit-j)
       (add-unit-filler clause-unit-k 'agent '*ellided*)
       (add-unit-filler clause-unit-j 'input-frame @clause_j)
       (add-unit-filler clause-unit-j 'marker 'because)
       (add-unit-fillers clause-unit-j 'textual-before 
         (list clause-unit-k clause-unit-j))
       (post-unit clause-unit-k 'plan-space)
       (post-unit clause-unit-j 'plan-space)
       (post-unit sentence-unit 'plan-space)))

Rule-1 unifies when there is a relationship of domain-causal-enablement 
linking two propositions, where the topic of the second clause is the
theme of the second proposition. If this is the case, then two
plan-clause units are instantiated for the two clauses, and a
plan-sentence unit is instantiated for a single complex sentence with
two clauses. The agent of the second proposition is ellided, and the
first clause is marked with because.

This rule makes use of a simple AND statement containing 4 =
statements that unify the rule and bind all the variables that are needed
in the right hand side. The right hand side is a series of DIBBS
function calls that instantiate, modify and post new text planning units as
appropriate.
 
This rule will for instance produce the basis architecture for the
following sentence:

   ``The fender of a car got dented because a boy threw a ball at it.'' 


(planner-rule Rule-2

IF (and (= @relation_i.type domain-causal)
        (= @relation_i.arguments^first @clause_j.proposition)
        (= @relation_i.arguments^second @clause_k.proposition)
        (= @clause_k.topic @clause_k.proposition.agent)
        (coreferential @clause_k.proposition.agent
                       @clause_j.proposition.agent)
        (not (= @clause_k.proposition.agent
                @clause_j.proposition.agent))
        (= @PF.formality high)
        (= @PF.simplicity low))

THEN (let* ((clause-unit-j (instantiate-unit 'plan-clause-unit))
            (clause-unit-k (instantiate-unit 'plan-clause-unit))
            (sentence-unit 
              (instantiate-unit 'plan-sentence-unit
                `((type sentence)(subtype complex)
                  (clauses ,clause-unit-k ,clause-unit-j)))))
       (add-unit-filler sentence-unit 'id sentence-unit)
       (add-unit-filler clause-unit-j 'input-frame @clause_j)
       (add-unit-filler clause-unit-j 'dependent-clause clause-unit-k)
       (add-unit-filler clause-unit-j 'agent 
         (referent @clause_j.proposition.agent))
       (add-unit-filler clause-unit-k 'input-frame @clause_k)
       (add-unit-filler clause-unit-k 'marker 'thereby)
       (add-unit-filler clause-unit-k 'agent 
         (referent @clause_k.proposition.agent)) 
       (add-unit-fillers clause-unit-k 'textual-before 
         (list clause-unit-j  clause-unit-k))
       (post-unit sentence-unit `plan-space)
       (post-unit clause-unit-j `plan-space)
       (post-unit clause-unit-k `plan-space)))

Rule-2 unifies when there is a domain-causal relationship between two
propositions, the topic of the second clause is the propositional
agent, and the agents of the two propositions are coreferential. The
intended formality must be high, and the intended simplicity, low. In
this case, a complex sentence with two clauses is planned, using the
marker whereby on the second clause.  This rule is similar to Rule-1,
but it uses a user-defined function call (COREFERENTIAL) and the NOT
operator.  This rule will produce the sentence:

 "A boy threw a ball at a car, thereby denting its fender."  


(planner-rule Rule-3

IF (and (= @trelation_i.type domain-causal)
        (= @trelation_i.arguments^first @clause_j.proposition)
        (= @trelation_i.arguments^second @clause_k.proposition)
        (= @clause_k.topic @clause_k.proposition.agent)
        (coreferential @clause_k.proposition.agent 
                       @clause_j.proposition.agent)
        (= @PF.force forceful)
        (= @PF.simplicity high))

THEN (let* ((clause-unit-k (instantiate-unit 'plan-clause-unit))
            (clause-unit-j (instantiate-unit 'plan-clause-unit))
            (sentence-unit-f (instantiate-unit `plan-sentence-unit
                               `((type sentence)(subtype simple)
                                 (clauses ,clause-unit-j))))
            (sentence-unit-g (instantiate-unit `plan-sentence-unit
                               `((type sentence)(subtype simple)
                                 (clauses ,clause-unit-k)))))
  (add-unit-filler sentence-unit-f 'id sentence-unit-f)
  (add-unit-filler sentence-unit-g 'id sentence-unit-g)
  (add-unit-fillers sentence-unit-g 'textual-before 
    (list sentence-unit-f sentence-unit-g))
  (add-unit-filler clause-unit-j 'agent 
    (referent @clause_j.proposition.agent))
  (add-unit-filler clause-unit-j 'input-frame @clause_j)
  (add-unit-filler clause-unit-k 'agent 
    (referent @clause_k.proposition.agent))
  (add-unit-filler clause-unit-k 'input-frame @clause_k)
  (post-unit clause-unit-k 'plan-space)
  (post-unit clause-unit-j 'plan-space)
  (post-unit sentence-unit-f 'plan-space)
  (post-unit sentence-unit-g 'plan-space))

Rule-3 handles a similar case, but when the intended force of
elocution is forceful, and the intended simplicity is high.

-------------------------------------------------------------------------------
REFERENCE RELATIONS

Rule-R1 and Rule-R2 concern reference relations between roles in the
TAMERLAN text. Rule-R1 will have the effect of elliding the realization of
a role. Rule-R2 handles pronominalization of roles.

(planner-rule Rule-R1

IF (and (= @plan-sentence-unit_unit_i.subtype and)
        (bind (@clause-j @clause-k)
              @plan-sentence-unit_unit_i.clauses
              @plan-sentence-unit_unit_i.clauses)
        (coreferential @clause-j.proposition.agent 
                       @clause-k.proposition.agent)
        (textual-before @clause-j @clause-k))

THEN  (replace-unit-filler @clause-k.proposition.agent 
        'head  '*ellided*))

Rule-R1 unifies when the planner has already decided to plan a
sentence of subtype AND. It binds the two clauses to be
conjoined, and checks to see if the two agents are coreferential. If
this is the case, then the second agent is ellided.

This rule will produce:

    "A boy threw a ball at a car and dented its fender" 

(planner-rule Rule-R2

IF (and (= @plan-sentence-unit_unit_i.type sentence)
        (= @plan-sentence-unit_unit_j.type sentence)
        (not (= @plan-sentence-unit_unit_j @plan-sentence-unit_unit_i))
        (textual-before @plan-sentence-unit_i @plan-sentence-unit_j)
        (bind (@proposition_i @proposition_j)
              @plan-sentence-unit_i.clause.proposition
              @plan-sentence-unit_j.clause.proposition))

THEN  (dolist (slot-i (proposition-role-slots @proposition-i))
        (dolist (slot-j (proposition-role-slots @proposition-j))
          (let ((x (get-value @proposition-i slot-i))
                (y (get-value @proposition-j slot-j)))
            (if (coreferential2 x y)
                (replace-unit-filler y 'head '*PRO*))))))

Rule-R2 will unify for any two distinct plan-sentence units that are
not co-occurrent, and there is some role present in both sentences
that has the same referent. For each such role, the head of the role
is replaced with a pronominal marker in the second sentence.

This rule will produce the sentence:

  ``A boy threw a ball at a car. He dented it.''

-------------------------------------------------------------------------------
ATTITUDES

Rule-A1, -A2, -A3 and -A4 concern attitudinals. Rule-A1 concerns
evaluative attitudinals, and Rule-A2, Rule-A3 and Rule-A4 concern
epistemic attitudinals.

(planner-rule Rule-A1

IF (and (= @clause_i.attitude.type evaluative)
        (= @clause_i.attitude.value low)
        (= @clause_i.attitude.scope @clause_i.proposition))

THEN  (let ((clause-unit-i (find-plan-unit 'plan-clause-unit @clause_i)))
        (add-unit-filler clause-unit-i 'attitude 'unfortunately)))

Rule-A1 introduces the marker unfortunately when the evaluative
attitude concerning the proposition is low.

This rule would produce a sentence like:

    ``Unfortunately, the ball dented the car.''

(planner-rule Rule-A2

IF (and (= @clause_i.attitude.type epistemic)
        (= @clause_i.attitude.value 1)
        (= @clause_i.attitude.scope @clause_i.proposition))

THEN (let ((clause-unit-i (find-plan-unit 'plan-clause-unit @clause_i)))
       (add-filler clause-unit-i 'features 'mood 'declarative)
       (replace-filler clause-unit-i 'features 'mood 'declarative)))

Rule-A2 indicates a simple realization using the declarative mood for
clauses that have an epistemic value of 1.

This rule would produce a sentence like:

   ``The boy threw the ball.''

(planner-rule Rule-A3
	      
IF (and (= @clause_i.attitude.type epistemic) 
        (= @clause_i.attitude.value 0) 
        (= @clause_i.attitude.scope @clause_i.proposition))

THEN (let ((clause-unit-i (find-plan-unit 'plan-clause-unit @clause_i)))
       (add-filler clause-unit-i 'features 'mood 'negative)))

Rule-A3 indicates a simple realization using negation for clauses that have
an epistemic value of 0.
 
This rule would produce a sentence like:

   ``The boy didn't throw the ball.''

(planner-rule Rule-A4

IF (and (= @clause_i.attitude.type epistemic)
        (= @clause_i.attitude.value 0.5)
        (= @clause_i.attitude.scope @clause_i.proposition))

THEN (let ((clause-unit-i (find-plan-unit 'plan-clause-unit @clause_i)))
       (add-unit-filler clause-unit-i 'attitude 'perhaps)))

Rule-A4 uses the attitude marker perhaps to indicate that there is a
non-zero possibility (here, a 50-50 chance) that the action occurred.

This rule would produce a sentence like:

   ``Perhaps the boy threw a ball.''

-------------------------------------------------------------------------------
TENSE

Rule-T1 marks a clause for past tense realization if the action
denoted by the clause took place before the time of the speech act.

(planner-rule Rule-T1

IF (and (= @relation_i.type intention-domain-after)
        (= @relation_i.arguments^first @speech-act_k.time)
        (= @relation_i.arguments^second @clause_j.time))

THEN (let ((clause-unit-j (find-plan-unit 'plan-clause-unit @clause_j)))
       (add-filler clause-unit-j 'features 'tense 'past)))

Rule-T1 unifies with clauses that took place before the time of the
speech act. It adds the feature (tense past) to any clauses in
the input that match this condition.