Example #1
0
class AddSubconjs(AddAuxWords):
    """
    Add subordinate conjunction a-nodes according to formemes.

    Arguments:
        language: the language of the target tree
        selector: the selector of the target tree
    """

    def __init__(self, scenario, args):
        "Constructor, just checking the argument values"
        Block.__init__(self, scenario, args)
        if self.language is None:
            raise LoadingException('Language must be defined!')
        self.lexicon = Lexicon()

    def get_aux_forms(self, tnode):
        "Find prepositional nodes to be created."
        match = re.match(r'^v:(.+)\+', tnode.formeme)
        if not match:
            return None
        # obtain the surface forms of the prepositions
        return match.group(1).split('_')

    def new_aux_node(self, anode, form):
        """\
        Create a subordinate conjunction node with the given
        conjunction form and parent.
        """
        new_node = anode.create_child()
        # inflect 'aby' and 'kdyby'
        if form in ['aby', 'kdyby']:
            new_node.form = self.lexicon.inflect_conditional(form,
                    anode.morphcat_number, anode.morphcat_person)
        else:
            new_node.form = form
        new_node.afun = 'AuxC'
        new_node.lemma = form
        new_node.morphcat_pos = 'J'
        new_node.shift_before_subtree(anode)
        return new_node
Example #2
0
class AddSubconjs(AddAuxWords):
    """
    Add subordinate conjunction a-nodes according to formemes.

    Arguments:
        language: the language of the target tree
        selector: the selector of the target tree
    """
    def __init__(self, scenario, args):
        "Constructor, just checking the argument values"
        Block.__init__(self, scenario, args)
        if self.language is None:
            raise LoadingException('Language must be defined!')
        self.lexicon = Lexicon()

    def get_aux_forms(self, tnode):
        "Find prepositional nodes to be created."
        match = re.match(r'^v:(.+)\+', tnode.formeme)
        if not match:
            return None
        # obtain the surface forms of the prepositions
        return match.group(1).split('_')

    def new_aux_node(self, anode, form):
        """\
        Create a subordinate conjunction node with the given
        conjunction form and parent.
        """
        new_node = anode.create_child()
        # inflect 'aby' and 'kdyby'
        if form in ['aby', 'kdyby']:
            new_node.form = self.lexicon.inflect_conditional(
                form, anode.morphcat_number, anode.morphcat_person)
        else:
            new_node.form = form
        new_node.afun = 'AuxC'
        new_node.lemma = form
        new_node.morphcat_pos = 'J'
        new_node.shift_before_subtree(anode)
        return new_node
class AddAuxVerbConditional(Block):
    """
    Add conditional auxiliary 'by'/'bych'.

    Arguments:
        language: the language of the target tree
        selector: the selector of the target tree
    """
    def __init__(self, scenario, args):
        "Constructor, just checking the argument values"
        Block.__init__(self, scenario, args)
        if self.language is None:
            raise LoadingException('Language must be defined!')
        self.lexicon = Lexicon()

    def process_tnode(self, tnode):
        "Add conditional auxiliary to a node, where appropriate."
        # check if we have to add a conditional auxiliary, end if not
        if tnode.gram_verbmod != 'cdn' or re.search(r'(aby|kdyby)',
                                                    tnode.formeme):
            return
        aconj = tnode.get_deref_attr('wild/conjugated')
        # create the new node
        if aconj.afun == 'AuxV':  # auxiliary conjugated -> make it a sibling
            acdn = aconj.parent.create_child()
        else:  # normal verb conjugated -> make it a child
            acdn = aconj.create_child()
        acdn.shift_before_node(aconj)
        acdn.lemma = 'být'
        acdn.afun = 'AuxV'
        acdn.morphcat_pos = 'V'
        acdn.morphcat_subpos = 'c'
        acdn.form = self.lexicon.inflect_conditional('by',
                                                     aconj.morphcat_number,
                                                     aconj.morphcat_person)
        # set tense of the original to past
        aconj.morphcat_subpos = 'p'
        # fix links
        tnode.add_aux_anodes(acdn)
Example #4
0
class AddAuxVerbConditional(Block):
    """
    Add conditional auxiliary 'by'/'bych'.

    Arguments:
        language: the language of the target tree
        selector: the selector of the target tree
    """

    def __init__(self, scenario, args):
        "Constructor, just checking the argument values"
        Block.__init__(self, scenario, args)
        if self.language is None:
            raise LoadingException("Language must be defined!")
        self.lexicon = Lexicon()

    def process_tnode(self, tnode):
        "Add conditional auxiliary to a node, where appropriate."
        # check if we have to add a conditional auxiliary, end if not
        if tnode.gram_verbmod != "cdn" or re.search(r"(aby|kdyby)", tnode.formeme):
            return
        aconj = tnode.get_deref_attr("wild/conjugated")
        # create the new node
        if aconj.afun == "AuxV":  # auxiliary conjugated -> make it a sibling
            acdn = aconj.parent.create_child()
        else:  # normal verb conjugated -> make it a child
            acdn = aconj.create_child()
        acdn.shift_before_node(aconj)
        acdn.lemma = "být"
        acdn.afun = "AuxV"
        acdn.morphcat_pos = "V"
        acdn.morphcat_subpos = "c"
        acdn.form = self.lexicon.inflect_conditional("by", aconj.morphcat_number, aconj.morphcat_person)
        # set tense of the original to past
        aconj.morphcat_subpos = "p"
        # fix links
        tnode.add_aux_anodes(acdn)