Class SimpleConnectionManager

  • All Implemented Interfaces:
    de.unirostock.sems.xmlutils.comparison.ConnectionManager

    public class SimpleConnectionManager
    extends Object
    implements de.unirostock.sems.xmlutils.comparison.ConnectionManager
    Author:
    Martin Scharm
    • Constructor Detail

      • SimpleConnectionManager

        public SimpleConnectionManager​(de.unirostock.sems.xmlutils.ds.TreeDocument docA,
                                       de.unirostock.sems.xmlutils.ds.TreeDocument docB)
        Instantiates a new simple connection manager.
        Parameters:
        docA - the original document
        docB - the modified document
    • Method Detail

      • scaleWeightOfAllConnections

        public void scaleWeightOfAllConnections​(double value)
        Scale the weight of all connections.
        Parameters:
        value - the scale
      • addWeightToAllConnections

        public void addWeightToAllConnections​(double value)
        Add weight to all connections.
        Parameters:
        value - the value to add
      • setWeightOfAllConnections

        public void setWeightOfAllConnections​(double value)
        Sets the weight of all connections.
        Parameters:
        value - the new weight of all connections
      • addConnection

        public boolean addConnection​(NodeConnection c)
                              throws BivesConnectionException
        Adds a new connection unless connection exists. If connection exists, the weights are summed. Throws exception if one of the nodes already connected.
        Parameters:
        c - the c connection to add
        Returns:
        true, if c was added
        Throws:
        BivesConnectionException
      • union

        public SimpleConnectionManager union​(SimpleConnectionManager cmgmt)
        Create a ConnectionManager that combines all connections from this ConnectionManager and another instance. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = A u B Use with caution, very expensive!
        Parameters:
        cmgmt - the ConnectionManager to join
        Returns:
        the united connection manager, containing all connections
      • intersection

        public SimpleConnectionManager intersection​(SimpleConnectionManager cmgmt)
        Create a ConnectionManager that contains only connections from this ConnectionManager and_another instance. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = A n B Use with caution, very expensive!
        Parameters:
        cmgmt - the cmgmt
        Returns:
        the connection manager
      • setDiff

        public SimpleConnectionManager setDiff​(SimpleConnectionManager cmgmt)
        Create a ConnectionManager that contains only connections from this ConnectionManager which are not included in another instance. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = A \ B Use with caution, very expensive!
        Parameters:
        cmgmt - the cmgmt
        Returns:
        the connection manager
      • symDiff

        public SimpleConnectionManager symDiff​(SimpleConnectionManager cmgmt)
        Create a ConnectionManager that contains only connections from this ConnectionManager and another instance and are not included in both managers. Weights are taken from this instance. E.g. given this is A and you pass B you'll get C = (A u B) \ (A n B) = (A \ B) u (B \ A) Use with caution, very VERY expensive!
        Parameters:
        cmgmt - the cmgmt
        Returns:
        the connection manager
      • dropConnection

        public void dropConnection​(de.unirostock.sems.xmlutils.ds.TreeNode node)
        Drop all connections of a node. In general you'll find a correct connection for a node, so you'll drop all connections and afterwards add the good one.
        Parameters:
        node - the node to liberate
      • dropConnection

        public void dropConnection​(de.unirostock.sems.xmlutils.comparison.Connection c)
        Drop a certain connection.
        Parameters:
        c - the connection
      • getConnectionForNode

        public de.unirostock.sems.xmlutils.comparison.Connection getConnectionForNode​(de.unirostock.sems.xmlutils.ds.TreeNode node)
        Gets the connections for node. Returns null if there is no connection for this node.
        Specified by:
        getConnectionForNode in interface de.unirostock.sems.xmlutils.comparison.ConnectionManager
        Parameters:
        node - the node
        Returns:
        the connections for node
      • getConnectionOfNodes

        public de.unirostock.sems.xmlutils.comparison.Connection getConnectionOfNodes​(de.unirostock.sems.xmlutils.ds.TreeNode a,
                                                                                      de.unirostock.sems.xmlutils.ds.TreeNode b)
        Gets the connection of two certain nodes. Returns null if nodes are not connected.
        Parameters:
        a - the a
        b - the b
        Returns:
        the connection of nodes
      • getUnmatched

        public List<de.unirostock.sems.xmlutils.ds.TreeNode> getUnmatched​(de.unirostock.sems.xmlutils.ds.TreeNode subtree,
                                                                          List<de.unirostock.sems.xmlutils.ds.TreeNode> unmatched)
        Gets the unmatched nodes in a subtree.
        Parameters:
        subtree - the subtree
        unmatched - the vector in which the unmatched nodes are collected
        Returns:
        the the vector in which the unmatched nodes are collected
      • deleteMatchedNodes

        public void deleteMatchedNodes​(List<de.unirostock.sems.xmlutils.ds.TreeNode> vec)
        Delete nodes of a vector which have connections.
        Parameters:
        vec - the vector of nodes to modify
      • parentsConnected

        public boolean parentsConnected​(de.unirostock.sems.xmlutils.comparison.Connection c)
        Check if parents connected. Parents are connected if there exists a connection between the parents of both nodes or both nodes don't have a parent (~> parents of two roots are connected!)
        Specified by:
        parentsConnected in interface de.unirostock.sems.xmlutils.comparison.ConnectionManager
        Parameters:
        c - the c
        Returns:
        true, if connected