Ejemplo n.º 1
0
    def method(self):

        """ Create new element according to elements in this embed. Can create
        constituentnodes,
        features, arrows, etc.
        :return: None
        """
        embed = self.get_ui_container()
        ci = embed.node_type_selector.currentIndex()
        node_type = embed.node_type_selector.itemData(ci)
        guess_mode = embed.guess_mode
        p1, p2 = embed.get_marker_points()
        text = embed.input_line_edit.text()
        ctrl.focus_point = p2
        node = None
        if guess_mode:
            node_type = guess_node_type(text)
        if node_type == g.ARROW:
            p1, p2 = embed.get_marker_points()
            text = embed.input_line_edit.text()
            ctrl.free_drawing.create_arrow(p2, p1, text)
        elif node_type == g.DIVIDER:
            p1, p2 = embed.get_marker_points()
            # fixme: finish this!
        elif node_type == g.TREE:
            node = ctrl.forest.simple_parse(text)
            if node:
                ctrl.forest.tree_manager.create_tree_for(node)
        else:
            node = ctrl.free_drawing.create_node(pos=p2, node_type=node_type, text=text)
            if node and node_type == g.CONSTITUENT_NODE:
                ctrl.forest.tree_manager.create_tree_for(node)
        if node:
            node.lock()
        ctrl.ui.close_active_embed()
Ejemplo n.º 2
0
 def guess_type_for_input(self, text):
     if not self.guess_mode:
         return
     key = guess_node_type(text)
     if key == 100:
         self.top_title.setText('Create new tree')
     else:
         self.top_title.setText('Create new ' + classes.node_info[key]['name'].lower())
Ejemplo n.º 3
0
 def guess_type_for_input(self, text):
     if not self.guess_mode:
         return
     key = guess_node_type(text)
     if key == 100:
         self.top_title.setText('Create new tree')
     else:
         self.top_title.setText('Create new ' + classes.node_info[key]['name'].lower())
Ejemplo n.º 4
0
    def method(self, focus_point, text, node_type=None, guess_mode=True):

        """ Create new element according to elements in this embed. Can create
        constituentnodes,
        features, arrows, etc.
        :return: None
        """
        ctrl.focus_point = focus_point
        if (not node_type) or node_type == g.GUESS_FROM_INPUT:
            if guess_mode:
                node_type = guess_node_type(text)
            else:
                node_type = g.CONSTITUENT_NODE
        if node_type == g.TREE:
            node = ctrl.forest.simple_parse(text)
        else:
            node = ctrl.drawing.create_node(pos=focus_point, node_type=node_type, label=text)
        if node:
            node.lock()
        ctrl.ui.close_active_embed()
        ctrl.forest.forest_edited()
Ejemplo n.º 5
0
 def method(self):
     """ Create new element according to elements in this embed. Can create
     constituentnodes,
     features, arrows, etc.
     :return: None
     """
     embed = self.get_ui_container()
     ci = embed.node_type_selector.currentIndex()
     node_type = embed.node_type_selector.itemData(ci)
     guess_mode = embed.guess_mode
     p1, p2 = embed.get_marker_points()
     text = embed.input_line_edit.text()
     ctrl.focus_point = p2
     node = None
     if guess_mode:
         node_type = guess_node_type(text)
     if node_type == g.ARROW:
         p1, p2 = embed.get_marker_points()
         text = embed.input_line_edit.text()
         ctrl.free_drawing.create_arrow(p2, p1, text)
     elif node_type == g.DIVIDER:
         p1, p2 = embed.get_marker_points()
         # fixme: finish this!
     elif node_type == g.TREE:
         node = ctrl.forest.simple_parse(text)
         #if node:
         #    ctrl.forest.tree_manager.create_tree_for(node)
     else:
         node = ctrl.free_drawing.create_node(pos=p2,
                                              node_type=node_type,
                                              label=text)
         #if node and node_type == g.CONSTITUENT_NODE:
         #    ctrl.forest.tree_manager.create_tree_for(node)
     if node:
         node.lock()
     ctrl.ui.close_active_embed()
     ctrl.forest.forest_edited()