Ejemplo n.º 1
0
 def __str__(self):
     label = as_text(self.label, single_line=True)
     syn_label = as_text(self.get_syn_label(), single_line=True)
     if label and syn_label:
         return f'CN {label} ({syn_label})'
     else:
         return f'CN {label or syn_label or "no label"}'
Ejemplo n.º 2
0
def figure_out_syntactic_label(cn):
    if cn.triangle_stack:
        # as_text -function puts triangle symbol before triangle content, [1:] removes it.
        return as_text(extract_triangle(cn.label), omit_index=True)[1:]
    l = as_text(cn.label, omit_index=True)
    if l:
        return l.splitlines()[0]
    else:
        return ''
Ejemplo n.º 3
0
def figure_out_syntactic_label(cn):
    if cn.triangle_stack:
        # as_text -function puts triangle symbol before triangle content, [1:] removes it.
        return as_text(extract_triangle(cn.label), omit_index=True)[1:]
    l = as_text(cn.label, omit_index=True)
    if l:
        return l.splitlines()[0]
    else:
        return ''
Ejemplo n.º 4
0
 def short_str(self):
     label = as_text(self.label)
     if label:
         lines = label.splitlines()
         if len(lines) > 3:
             label = f'{lines[0]} ...\n{lines[-1]}'
     syn_label = as_text(self.get_syn_label())
     if label and syn_label:
         return f'{label} ({syn_label})'
     else:
         return label or syn_label or "no label"
Ejemplo n.º 5
0
    def update_status_tip(self) -> None:
        """ Hovering status tip """

        if self.label:
            label = f'Label: "{as_text(self.label)}" '
        else:
            label = ''
        syn_label = self.get_syn_label()
        if syn_label:
            syn_label = f' Constituent: "{as_text(syn_label)}" '
        else:
            syn_label = ''
        if self.index:
            index = f' Index: "{self.index}"'
        else:
            index = ''

        if self.is_trace:
            name = "Trace"
        elif self.is_leaf():
            name = "Leaf "
        # elif self.is_top_node():
        #    name = "Set %s" % self.set_string() # "Root constituent"
        else:
            #name = f"Set {self.set_string()}"
            name = "Set "
        if self.use_adjustment:
            adjustment = f' w. adjustment ({self.adjustment[0]:.1f}, {self.adjustment[1]:.1f})'
        else:
            adjustment = ''
        heads = ', '.join([as_text(x.label) for x in self.heads])
        self.status_tip = f"{name} ({label}{syn_label}{index} pos: ({self.current_scene_position[0]:.1f}, " \
                          f"{self.current_scene_position[1]:.1f}){adjustment} head: {heads})"
Ejemplo n.º 6
0
 def get_base_label(node):
     head_part = as_text(node.label, omit_triangle=True, omit_index=True)
     if head_part:
         head_part = head_part.splitlines()[0].strip()
         last_char = head_part[-1]
         if len(head_part) > 1 and last_char in ('P', "'", "´"):
             head_part = head_part[:-1]
     return head_part
Ejemplo n.º 7
0
 def get_base_label(node):
     head_part = as_text(node.label, omit_triangle=True, omit_index=True)
     if head_part:
         head_part = head_part.splitlines()[0].strip()
         last_char = head_part[-1]
         if len(head_part) > 1 and last_char in ('P', "'", "´"):
             head_part = head_part[:-1]
     return head_part