From: <jen...@us...> - 2008-07-30 16:13:43
|
Revision: 1030 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1030&view=rev Author: jenslehmann Date: 2008-07-30 16:13:37 +0000 (Wed, 30 Jul 2008) Log Message: ----------- partially implemented EL description trees Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java trunk/src/dl-learner/org/dllearner/algorithms/el/Edge.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-07-30 14:49:02 UTC (rev 1029) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELDescriptionTree.java 2008-07-30 16:13:37 UTC (rev 1030) @@ -19,14 +19,23 @@ */ package org.dllearner.algorithms.el; +import java.util.LinkedList; import java.util.List; import java.util.SortedSet; +import java.util.TreeSet; import org.dllearner.core.owl.NamedClass; /** - * Represents an EL description tree. + * Represents an EL description tree, which corresponds to a + * description in the EL description logic. Note that an EL description tree + * can be a subtree of another EL description tree. In general, + * an EL description tree is a tree where the node label is a set + * of named classes and the edges are labelled with a property. * + * In the documentation below "this node" refers to the root node + * of this EL description (sub-)tree. + * * @author Jens Lehmann * */ @@ -36,15 +45,84 @@ private List<Edge> edges; + // parent node in the tree; + // null indicates that this node is a root node + private ELDescriptionTree parent = null; + /** - * @return the label + * Constructs an empty EL description tree with the empty set + * as root label and an empty set of outgoing edges. */ + public ELDescriptionTree() { + this(new TreeSet<NamedClass>(), new LinkedList<Edge>()); + } + + /** + * Constructs an EL description tree given its root label. + * @param label Label of the root node. + */ + public ELDescriptionTree(SortedSet<NamedClass> label) { + this(label, new LinkedList<Edge>()); + } + + /** + * Constructs an EL description tree given its root label and edges. + * @param label Label of the root node. + * @param edges Edges connected to the root node. + */ + public ELDescriptionTree(SortedSet<NamedClass> label, List<Edge> edges) { + this.label = label; + this.edges = edges; + } + + /** + * Checks whether this node has a parent. If the parent link + * is null, the node is considered to be a root node. + * @return True of this is the root node and false otherwise. + */ + public boolean isRoot() { + return parent == null; + } + + /** + * Traverses the EL description tree upwards until it finds + * the root and returns it. + * @return The root node of this EL description tree. + */ + public ELDescriptionTree getRoot() { + ELDescriptionTree root = this; + while(root.parent != null) { + root = parent; + } + return root; + } + + /** + * Traverses the tree until the root node and counts how + * many edges are traversed. If this node does not have a parent, + * zero is returned. + * @return The level of this node (or more specifically the root + * node of this subtree) within the overall EL description tree. + */ + public int getLevel() { + ELDescriptionTree root = this; + int level = 0; + while(root.parent != null) { + root = parent; + level++; + } + return level; + } + + /** + * @return The label of root node of this subtree. + */ public SortedSet<NamedClass> getLabel() { return label; } /** - * @return the edges + * @return The outgoing edges of this subtree. */ public List<Edge> getEdges() { return edges; Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/Edge.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/Edge.java 2008-07-30 14:49:02 UTC (rev 1029) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/Edge.java 2008-07-30 16:13:37 UTC (rev 1030) @@ -19,12 +19,44 @@ */ package org.dllearner.algorithms.el; +import org.dllearner.core.owl.ObjectProperty; + /** - * An edge in an EL description tree. + * A (directed) edge in an EL description tree. It consists of an edge + * label, which is an object property, and the EL description tree + * the edge points to. * * @author Jens Lehmann * */ public class Edge { + private ObjectProperty label; + + private ELDescriptionTree tree; + + /** + * Constructs and edge given a label and an EL description tree. + * @param label The label of this edge. + * @param tree The tree the edge points to (edges are directed). + */ + public Edge(ObjectProperty label, ELDescriptionTree tree) { + this.label = label; + this.tree = tree; + } + + /** + * @return The label of this edge. + */ + public ObjectProperty getLabel() { + return label; + } + + /** + * @return The EL description tree + */ + public ELDescriptionTree getTree() { + return tree; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |