Exemplo n.º 1
0
    def rehash(self):
        '''when the children nodes are re-set, recompute relevant info. used by local_feats.py'''
        self._coordination = None
        self._str = None
        self.is_coordination()
        self.__str__()

        for htype in htypes:
            if self.is_terminal():
                self.set_headchild(htype, self)                
            else:
                self.set_headchild(htype, heads.headchild(htype, self))
Exemplo n.º 2
0
    def rehash(self):
        '''when the children nodes are re-set, recompute relevant info. used by local_feats.py'''
        self._coordination = None
        self._str = None
        self.is_coordination()
        self.__str__()

        for htype in htypes:
            if self.is_terminal():
                self.set_headchild(htype, self)
            else:
                self.set_headchild(htype, heads.headchild(htype, self))
Exemplo n.º 3
0
    def annotate(self, max_outs, parentlabel=None, do_sub=True, dep=0):
        ''' this is TOP-DOWN annotation.
		    max-outs = { SYN: (max, out), SEM: (max1, out1) }
		'''

        self.parentlabel = parentlabel
        if max_outs is not None:
            self.set_max_outs(max_outs)

        if self.is_terminal():
            for htype in htypes:
                self.set_lexhead(htype, heads.LexHead(self))
                self.set_headchild(htype, self)

        else:
            for htype in htypes:
                self.set_headchild(htype, heads.headchild(htype, self))
##				print >> logs, " " * dep, self.labelspan(), htype, heads.headchild(htype, self)

            if do_sub:
                headss = {}
                for htype in htypes:
                    headss[htype] = self.get_headchild(htype)
                for sub in self.subs:
                    if max_outs is not None:
                        new_max_outs = {}
                        for htype in htypes:
                            ### SUPER CAUTION! is, not ==; otherwise parallels like "rally, rally, rally"
                            if sub is headss[htype]:
                                ## i am head, so adopt parent's max_outs
                                new_max_outs[htype] = max_outs[htype]
                            else:
                                ## head changes at this level
                                new_max_outs[htype] = (sub, self)
                    else:
                        new_max_outs = None

                    sub.annotate(new_max_outs, self.label, dep + 1)

            for htype in htypes:
                self.set_lexhead(htype,
                                 self.get_headchild(htype).get_lexhead(htype))

                if print_heads:
                    print " |  " * dep, self.spanlabel(
                    ), " ", self.get_lexhead(htype)
Exemplo n.º 4
0
    def annotate(self, max_outs, parentlabel=None, do_sub=True, dep=0):
        ''' this is TOP-DOWN annotation.
            max-outs = { SYN: (max, out), SEM: (max1, out1) }
        '''

        self.parentlabel = parentlabel
        if max_outs is not None:
            self.set_max_outs(max_outs)        
            
        if self.is_terminal():
            for htype in htypes:
                self.set_lexhead(htype, heads.LexHead(self))
                self.set_headchild(htype, self)

        else:
            for htype in htypes:
                self.set_headchild(htype, heads.headchild(htype, self))
##                print >> logs, " " * dep, self.labelspan(), htype, heads.headchild(htype, self)

            if do_sub:
                headss = {}
                for htype in htypes:
                    headss[htype] = self.get_headchild(htype)
                for sub in self.subs:
                    if max_outs is not None:
                        new_max_outs = {}
                        for htype in htypes:
                            ### SUPER CAUTION! is, not ==; otherwise parallels like "rally, rally, rally"
                            if sub is headss[htype]:
                                ## i am head, so adopt parent's max_outs
                                new_max_outs [htype] = max_outs [htype]
                            else:
                                ## head changes at this level
                                new_max_outs [htype] = (sub, self)
                    else:
                        new_max_outs = None

                    sub.annotate(new_max_outs, self.label, dep+1)                    
            
            for htype in htypes:
                self.set_lexhead(htype, self.get_headchild(htype).get_lexhead(htype))
                
                if print_heads:
                    print " |  " * dep, self.spanlabel(), " ", self.get_lexhead(htype)