Example #1
0
    def to_surface(self, transform_state, say_state, idiolect):
        argx_to_front = decide_arg_to_front(self.rels_vargs, self.purpose,
                                            self.subj_index)

        # Verb context.
        voice = self.decide_voice()
        conj = self.decide_conjugation(transform_state, say_state, idiolect)
        assert conj
        is_fronting = argx_to_front is not None
        info = transform_state.purpose_mgr.get(self.purpose)
        is_split = info.split_verb(is_fronting)
        relative_cont = RelativeContainment.NOT_REL
        contract_not = idiolect.contractions
        split_inf = idiolect.split_infinitive
        if idiolect.subjunctive_were:
            sbj_handling = SubjunctiveHandling.WERE_SBJ
        else:
            sbj_handling = SubjunctiveHandling.WAS_SBJ
        surface_verb = SurfaceVerb(self.verb, voice, conj, is_split,
                                   relative_cont, contract_not, split_inf,
                                   sbj_handling)
        surface_verb.check(allow_wildcards=False)

        # Figure out prepositions for our relations.
        rels_types = []
        for rel, arg in self.rels_vargs:
            rels_types.append((rel, arg.relation_arg_type()))
        preps = transform_state.relation_mgr.decide_preps(
            rels_types, self.subj_index)

        # Build list of properly prepositioned surface arguments (without
        # fronting or imperative subject omission).
        orig_preps_surfs = []
        for (rel, arg), prep in zip(self.rels_vargs, preps):
            surface = arg.to_surface(transform_state, say_state, idiolect)
            orig_preps_surfs.append((prep, surface))

        # If imperative, we disappear the subject ("do this" vs "you do this").
        is_imperative = self.verb.modality.flavor == ModalFlavor.IMPERATIVE

        # Apply transformations to get surface structure for args (eg,
        # fronting).
        preps_surfs, vmain_index = transform(orig_preps_surfs, self.subj_index,
                                             is_imperative, argx_to_front,
                                             idiolect.stranding)

        # Get the complementizer.
        complementizer = STATUS2COMPLEMENTIZER[self.status]

        return SurfaceContentClause(complementizer, surface_verb, self.adverbs,
                                    preps_surfs, vmain_index)