Skip to content

Commit 06845b0

Browse files
Merge branch 'develop' of github.com:SmartDataAnalytics/DL-Learner into develop
2 parents db4f6f1 + 42e7d00 commit 06845b0

55 files changed

Lines changed: 1852 additions & 1650 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README renamed to README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ knowledge (usually in description logics, hence the "DL" in its name). Please
33
check the website for details and examples. Post to the mailing list if help
44
is needed.
55

6-
Website: http://dl-learner.org
7-
Bugs & Feature Requests: https://github.com/SmartDataAnalytics/DL-Learner/issues
8-
Mailing Lists: [DL-Learner Discussion](https://www.freelists.org/list/dl-learner-discussion)
9-
Latest Release: https://github.com/SmartDataAnalytics/DL-Learner/releases
6+
* Website: http://dl-learner.org
7+
* Bugs & Feature Requests: https://github.com/SmartDataAnalytics/DL-Learner/issues
8+
* Mailing Lists: [DL-Learner Discussion](https://www.freelists.org/list/dl-learner-discussion)
9+
* Latest Release: https://github.com/SmartDataAnalytics/DL-Learner/releases
1010

1111
Documentation for DL-Learner:
1212
* please visit http://dl-learner.org for general information
@@ -16,7 +16,7 @@ Documentation for DL-Learner:
1616
* Docker: https://github.com/SmartDataAnalytics/DL-Learner/tree/develop/docker
1717

1818
DL-Learner is Open Source and licensed under the GNU General Public License 3.
19-
(Copyright (c) 2007-2018, Jens Lehmann).
19+
(Copyright (c) 2007-2019, Jens Lehmann).
2020

2121
DL-Learner uses several other libraries. An incomplete list is as follows:
2222
* [OWL API](https://owlcs.github.io/owlapi/) (licensed under LGPL)

components-core/pom.xml

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
<parent>
1111
<groupId>org.dllearner</groupId>
1212
<artifactId>dllearner-parent</artifactId>
13-
<version>1.3.1-SNAPSHOT</version>
13+
<version>1.4.1-SNAPSHOT</version>
1414
</parent>
1515

16+
<properties>
17+
<automatic.module.name>org.dllearner</automatic.module.name>
18+
</properties>
19+
1620
<profiles>
1721
<profile>
1822
<id>release</id>
@@ -331,6 +335,24 @@
331335
<dependency>
332336
<groupId>net.sourceforge.owlapi</groupId>
333337
<artifactId>org.semanticweb.hermit</artifactId>
338+
<exclusions>
339+
<exclusion>
340+
<groupId>commons-logging</groupId>
341+
<artifactId>commons-logging</artifactId>
342+
</exclusion>
343+
<exclusion>
344+
<groupId>org.apache.geronimo.specs</groupId>
345+
<artifactId>geronimo-activation_1.1_spec</artifactId>
346+
</exclusion>
347+
<exclusion>
348+
<groupId>org.apache.geronimo.specs</groupId>
349+
<artifactId>geronimo-javamail_1.4_spec</artifactId>
350+
</exclusion>
351+
<exclusion>
352+
<groupId>org.apache.geronimo.specs</groupId>
353+
<artifactId>geronimo-stax-api_1.0_spec</artifactId>
354+
</exclusion>
355+
</exclusions>
334356
</dependency>
335357

336358
<dependency>
@@ -404,6 +426,12 @@
404426
<dependency>
405427
<groupId>org.springframework</groupId>
406428
<artifactId>spring-beans</artifactId>
429+
<exclusions>
430+
<exclusion>
431+
<groupId>commons-logging</groupId>
432+
<artifactId>commons-logging</artifactId>
433+
</exclusion>
434+
</exclusions>
407435
</dependency>
408436
<dependency>
409437
<groupId>org.apache.lucene</groupId>
@@ -441,7 +469,13 @@
441469
<dependency>
442470
<groupId>com.thoughtworks.xstream</groupId>
443471
<artifactId>xstream</artifactId>
444-
<version>1.4.11.1</version>
472+
<version>1.4.13</version>
473+
<exclusions>
474+
<exclusion>
475+
<groupId>xpp3</groupId>
476+
<artifactId>xpp3_min</artifactId>
477+
</exclusion>
478+
</exclusions>
445479
</dependency>
446480
<!--
447481
<dependency>
@@ -495,11 +529,13 @@
495529
</dependency>
496530

497531
<!-- https://mvnrepository.com/artifact/org.tinyjee.jgraphx/jgraphx -->
532+
<!--
498533
<dependency>
499534
<groupId>org.tinyjee.jgraphx</groupId>
500535
<artifactId>jgraphx</artifactId>
501536
<version>3.4.1.3</version>
502537
</dependency>
538+
-->
503539

504540
<!--
505541
<dependency>
@@ -533,12 +569,30 @@
533569
<artifactId>commons-httpclient</artifactId>
534570
<groupId>commons-httpclient</groupId>
535571
</exclusion>
572+
<exclusion>
573+
<artifactId>commons-beanutils-core</artifactId>
574+
<groupId>commons-beanutils</groupId>
575+
</exclusion>
576+
<exclusion>
577+
<groupId>commons-logging</groupId>
578+
<artifactId>commons-logging</artifactId>
579+
</exclusion>
536580
</exclusions>
537581
</dependency>
538582

539583
<dependency>
540584
<groupId>edu.berkeley.compbio</groupId>
541585
<artifactId>jlibsvm</artifactId>
586+
<exclusions>
587+
<exclusion>
588+
<groupId>com.martiansoftware</groupId>
589+
<artifactId>JSAP</artifactId>
590+
</exclusion>
591+
<exclusion>
592+
<groupId>commons-logging</groupId>
593+
<artifactId>commons-logging</artifactId>
594+
</exclusion>
595+
</exclusions>
542596
</dependency>
543597

544598
<dependency>
@@ -550,7 +604,7 @@
550604
<dependency>
551605
<groupId>org.reflections</groupId>
552606
<artifactId>reflections</artifactId>
553-
<version>0.9.11</version>
607+
<version>0.9.12</version>
554608
</dependency>
555609

556610
<dependency>
@@ -590,16 +644,16 @@
590644
<artifactId>jaxws-api</artifactId>
591645
</dependency>
592646

593-
<dependency>
594-
<groupId>org.apache.logging.log4j</groupId>
595-
<artifactId>log4j-api</artifactId>
596-
<version>2.12.1</version>
597-
</dependency>
598-
<dependency>
599-
<groupId>org.apache.logging.log4j</groupId>
600-
<artifactId>log4j-core</artifactId>
601-
<version>2.12.1</version>
602-
</dependency>
647+
<dependency>
648+
<groupId>org.apache.logging.log4j</groupId>
649+
<artifactId>log4j-api</artifactId>
650+
<version>${log4j.version}</version>
651+
</dependency>
652+
<dependency>
653+
<groupId>org.apache.logging.log4j</groupId>
654+
<artifactId>log4j-core</artifactId>
655+
<version>${log4j.version}</version>
656+
</dependency>
603657

604658
</dependencies>
605659
</project>

components-core/src/etc/overview.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
<p>
1010
Project Homepage: <a href="http://dl-learner.org">http://dl-learner.org</a> <br />
11-
GitHub Website: <a href="https://github.com/AKSW/DL-Learner/">https://github.com/AKSW/DL-Learner/</a>
11+
GitHub Website: <a href="https://github.com/SmartDataAnalytics/DL-Learner/">https://github.com/AKSW/DL-Learner/</a>
1212
</p>
1313

1414
<p><img src="https://raw.githubusercontent.com/github/media/master/octocats/blacktocat-16.png" border="0" alt="GitHub Logo" /></p>
1515

1616
</body>
17-
</html>
17+
</html>

components-core/src/main/java/org/dllearner/core/AbstractReasonerComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public abstract class AbstractReasonerComponent extends AbstractComponent implem
142142
@ConfigOption(description = "the underlying knowledge sources", required = true)
143143
protected Set<KnowledgeSource> sources;
144144

145-
public AbstractReasonerComponent(){
145+
public AbstractReasonerComponent(){
146146

147147
}
148148
/**

components-core/src/main/java/org/dllearner/core/owl/AbstractHierarchy.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,26 @@ public SortedSet<T> getChildren(T entity, boolean direct) {
8181
SortedSet<T> result = hierarchyDown.get(entity);
8282

8383
if(result == null) {
84-
logger.debug("Query for " + entity + " in hierarchy, but the entity is not contained in the (downward) hierarchy, e.g. because the entity does not exist or is ignored. Returning empty result instead.");
84+
logger.debug("Query for " + entity + " in hierarchy, but the entity is not contained in the (downward)" +
85+
" hierarchy, e.g. because the entity does not exist or is ignored. Returning empty result instead.");
8586
return new TreeSet<>();
8687
}
87-
88+
89+
// create new set because we'll modify the set
90+
result = new TreeSet<>(result);
91+
92+
// depending on the reasoner implementation, the entity itself is trivially contained, so remove it here
8893
result.remove(entity);
94+
95+
// recursive call for decendants
8996
if(!direct) { // get transitive children
9097
SortedSet<T> tmp = new TreeSet<>();
9198
for(T child : result){
9299
tmp.addAll(getChildren(child, direct));
93100
}
94101
result.addAll(tmp);
95102
}
96-
return new TreeSet<>(result);
103+
return result;
97104
}
98105

99106
/* (non-Javadoc)
@@ -112,11 +119,18 @@ public SortedSet<T> getParents(T entity, boolean direct) {
112119
SortedSet<T> result = hierarchyUp.get(entity);
113120

114121
if(result == null) {
115-
logger.debug("Query for " + entity + " in hierarchy, but the entity is not contained in the (upward) hierarchy, e.g. because the entity does not exist or is ignored. Returning empty result instead.");
122+
logger.debug("Query for " + entity + " in hierarchy, but the entity is not contained in the (upward) " +
123+
"hierarchy, e.g. because the entity does not exist or is ignored. Returning empty result instead.");
116124
return new TreeSet<>();
117125
}
118-
126+
127+
// create new set because we'll modify the set
128+
result = new TreeSet<>(result);
129+
130+
// depending on the reasoner implementation, the entity itself is trivially contained, so remove it here
119131
result.remove(entity);
132+
133+
// recursive call for ancestors
120134
if(!direct) {
121135
SortedSet<T> tmp = new TreeSet<>();
122136
for(T parent : result){
@@ -125,7 +139,7 @@ public SortedSet<T> getParents(T entity, boolean direct) {
125139
result.addAll(tmp);
126140
}
127141

128-
return new TreeSet<>(result);
142+
return result;
129143
}
130144

131145
/* (non-Javadoc)

components-core/src/main/java/org/dllearner/core/owl/ClassHierarchy.java

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
*/
1919
package org.dllearner.core.owl;
2020

21-
import java.util.HashSet;
22-
import java.util.Set;
23-
import java.util.SortedMap;
24-
import java.util.SortedSet;
25-
import java.util.TreeSet;
21+
import java.util.*;
22+
import java.util.stream.Collectors;
23+
import java.util.stream.Stream;
2624

2725
import org.semanticweb.owlapi.model.OWLAxiom;
2826
import org.semanticweb.owlapi.model.OWLClass;
@@ -31,7 +29,6 @@
3129
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;
3230
import org.slf4j.Logger;
3331
import org.slf4j.LoggerFactory;
34-
3532
import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl;
3633
import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl;
3734

@@ -122,33 +119,56 @@ public boolean isSubclassOf(OWLClassExpression subClass, OWLClassExpression supe
122119

123120
@Override
124121
public ClassHierarchy clone() {
125-
return new ClassHierarchy(getHierarchyUp(), getHierarchyDown());
122+
return new ClassHierarchy(new TreeMap<>(getHierarchyUp()), new TreeMap<>(getHierarchyDown()));
126123
}
127-
128-
public Set<OWLAxiom> toOWLAxioms(){
129-
return toOWLAxioms(OWL_THING);
124+
125+
/**
126+
* Converts the class hierarchy to a set of subclass axioms.
127+
*
128+
* @return a set of subclass axioms
129+
*/
130+
public Set<OWLAxiom> toOWLAxioms() {
131+
return getEntities().stream().flatMap(cls ->
132+
Optional.ofNullable(getChildren(cls)).map(Collection::stream).orElseGet(Stream::empty)
133+
.map(sub -> df.getOWLSubClassOfAxiom(sub, cls))
134+
).collect(Collectors.toSet());
130135
}
131-
132-
public Set<OWLAxiom> toOWLAxioms(OWLClassExpression concept){
136+
137+
/**
138+
* Converts the class hierarchy starting from the given concept <code>ce</code> to a set of subclass axioms.
139+
*
140+
* @param ce the root
141+
* @return a set of subclass axioms
142+
*/
143+
public Set<OWLAxiom> toOWLAxioms(OWLClassExpression ce) {
133144
Set<OWLAxiom> axioms = new HashSet<>();
134-
Set<OWLClassExpression> subConcepts = getChildren(concept);
135-
if (subConcepts != null) {
136-
for (OWLClassExpression sub : subConcepts){
137-
axioms.add(df.getOWLSubClassOfAxiom(sub, concept));
138-
axioms.addAll(toOWLAxioms(sub));
145+
Set<OWLClassExpression> visited = new HashSet<>();
146+
Set<OWLClassExpression> subclasses = getChildren(ce);
147+
if (subclasses != null) {
148+
for (OWLClassExpression sub : subclasses) {
149+
axioms.add(df.getOWLSubClassOfAxiom(sub, ce));
150+
toOWLAxioms(sub, axioms, visited);
139151
}
140152
}
141153
return axioms;
142154
}
155+
156+
private void toOWLAxioms(OWLClassExpression ce, Set<OWLAxiom> axioms, Set<OWLClassExpression> visited){
157+
visited.add(ce);
158+
159+
Optional.ofNullable(getChildren(ce)).map(Collection::stream).orElseGet(Stream::empty)
160+
.filter(cls -> !visited.contains(cls))
161+
.forEach(sub -> {
162+
axioms.add(df.getOWLSubClassOfAxiom(sub, ce));
163+
toOWLAxioms(sub, axioms, visited);
164+
});
165+
}
143166

144167
public int getDepth2Root(OWLClassExpression concept){
145168
SortedSet<OWLClassExpression> superClasses = getParents(concept);
146-
int depth = 0;
169+
int depth = 1;
147170
if(superClasses != null){
148-
depth = 1;
149-
for(OWLClassExpression superClass : superClasses){
150-
depth += getDepth2Root(superClass);
151-
}
171+
depth += superClasses.stream().mapToInt(this::getDepth2Root).max().getAsInt();
152172
}
153173
return depth;
154174
}
@@ -172,4 +192,6 @@ public OWLClassExpression getTopConcept() {
172192
public OWLClassExpression getBottomConcept() {
173193
return OWL_NOTHING;
174194
}
195+
196+
175197
}

components-core/src/main/java/org/dllearner/core/owl/DatatypePropertyHierarchy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.util.SortedMap;
2222
import java.util.SortedSet;
23+
import java.util.TreeMap;
2324
import java.util.TreeSet;
2425

2526
import org.semanticweb.owlapi.model.OWLDataProperty;
@@ -93,6 +94,6 @@ public OWLDataProperty getBottomConcept() {
9394

9495
@Override
9596
public DatatypePropertyHierarchy clone() {
96-
return new DatatypePropertyHierarchy(getHierarchyUp(), getHierarchyDown());
97+
return new DatatypePropertyHierarchy(new TreeMap<>(getHierarchyUp()), new TreeMap<>(getHierarchyDown()));
9798
}
9899
}

components-core/src/main/java/org/dllearner/core/owl/ObjectPropertyHierarchy.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
*/
1919
package org.dllearner.core.owl;
2020

21-
import java.util.Set;
22-
import java.util.SortedMap;
23-
import java.util.SortedSet;
24-
import java.util.TreeSet;
21+
import java.util.*;
2522

2623
import org.semanticweb.owlapi.model.OWLObjectProperty;
2724
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;
@@ -115,6 +112,6 @@ protected String toString(SortedMap<OWLObjectProperty, SortedSet<OWLObjectProper
115112

116113
@Override
117114
public ObjectPropertyHierarchy clone() {
118-
return new ObjectPropertyHierarchy(getHierarchyUp(), getHierarchyDown());
115+
return new ObjectPropertyHierarchy(new TreeMap<>(getHierarchyUp()), new TreeMap<>(getHierarchyDown()));
119116
}
120117
}

0 commit comments

Comments
 (0)