1
1
package org .dice_group .lpbenchgen .dl .creator ;
2
2
3
3
import com .google .common .collect .Lists ;
4
+ import com .google .common .collect .Sets ;
4
5
import org .dice_group .lpbenchgen .config .Configuration ;
5
6
import org .dice_group .lpbenchgen .config .PosNegExample ;
6
7
import org .dice_group .lpbenchgen .dl .ConceptLengthCalculator ;
@@ -72,6 +73,7 @@ public OWLTBoxPositiveCreator(Configuration conf, IndividualRetriever retriever,
72
73
seed =conf .getSeed ();
73
74
negationMutationRatio =conf .getNegationMutationRatio ();
74
75
inferDirectSuperClasses =conf .getInferDirectSuperClasses ();
76
+ negationMutationRandom = new Random (seed );
75
77
76
78
}
77
79
@@ -86,7 +88,6 @@ public List<String> getAllowedTypes() {
86
88
87
89
@ Override
88
90
public Collection <PosNegExample > createDistinctConcepts (int noOfConcepts ){
89
- negationMutationRandom = new Random (seed );
90
91
Set <PosNegExample > ret = new HashSet <>();
91
92
int toSmallCount =0 ;
92
93
int noResults =0 ;
@@ -143,7 +144,11 @@ protected Double getConceptLength(OWLClassExpression concept) {
143
144
}
144
145
145
146
146
- private Collection <OWLClassExpression > createConcepts (){
147
+ /**
148
+ * Creates a list of class expressions
149
+ * @return a list of class expressions
150
+ */
151
+ public Collection <OWLClassExpression > createConcepts (){
147
152
List <OWLClassExpression > concepts = new ArrayList <>();
148
153
List <String > allowedTypes = new ArrayList <>(this .allowedTypes );
149
154
for (String type : allowedTypes ){
@@ -183,37 +188,41 @@ private Set<OWLAxiom> getAxiomsForClass(OWLClass owlClass) {
183
188
}
184
189
185
190
186
- private Collection <OWLClassExpression > createConceptsFromClass (OWLClass owlClass ){
191
+ /**
192
+ * Creates a list of class expressions starting at the owlClass
193
+ * @param owlClass start point of the class expressions
194
+ * @return list of class expressions
195
+ */
196
+ protected Collection <OWLClassExpression > createConceptsFromClass (OWLClass owlClass ){
187
197
Collection <OWLClassExpression > ret = new ArrayList <>();
188
198
ret .add (owlClass );
189
199
addNegationMutation (ret , owlClass );
190
200
createConceptFromExpression (owlClass , ret );
191
201
getAxiomsForClass (owlClass ).forEach (axiom ->{
192
202
if (axiom instanceof OWLObjectPropertyRangeAxiom ){
193
- createConceptFromExpression (((OWLObjectPropertyRangeAxiom ) axiom ), ret );
203
+ createConceptFromExpression (owlClass , ((OWLObjectPropertyRangeAxiom ) axiom ), ret );
194
204
}
195
205
196
206
});
197
207
return ret ;
198
208
}
199
209
200
- private void createConceptFromExpression (OWLObjectPropertyRangeAxiom ax , Collection <OWLClassExpression > ret ) {
210
+ private void createConceptFromExpression (OWLClass start , OWLObjectPropertyRangeAxiom ax , Collection <OWLClassExpression > ret ) {
201
211
if (1 <= maxDepth ) {
202
212
OWLObjectPropertyExpression prop = ax .getProperty ();
203
- OWLClassExpression owlClass2 = ax .getRange ();
204
- OWLClassExpression propExpr = new OWLObjectSomeValuesFromImpl (prop , owlClass2 );
213
+ OWLClassExpression propExpr = new OWLObjectSomeValuesFromImpl (prop , start );
205
214
if (getConceptLength (propExpr ) <= maxConceptLength ) {
206
215
ret .add (propExpr );
207
216
208
217
addNegationMutation (ret , propExpr );
209
- for (OWLClassExpression expr : createConceptFromExpression (owlClass2 , getRangePropertiesForClass (( OWLClass ) owlClass2 ), 1 + 1 )) {
218
+ for (OWLClassExpression expr : createConceptFromExpression (start , getRangePropertiesForClass (start ), 1 + 1 )) {
210
219
OWLClassExpression pexpr = new OWLObjectSomeValuesFromImpl (prop , expr );
211
220
if (getConceptLength (pexpr ) <= maxConceptLength ) {
212
221
addNegationMutation (ret , pexpr );
213
222
ret .add (pexpr );
214
223
}
215
224
}
216
- for (OWLClass inferredClass : res .getSubClasses (owlClass2 ).getFlattened ()) {
225
+ for (OWLClass inferredClass : res .getSubClasses (start ).getFlattened ()) {
217
226
if (allowedTypes .contains (inferredClass .getIRI ().toString ())) {
218
227
OWLClassExpression negationPropExpr = new OWLObjectSomeValuesFromImpl (prop , inferredClass );
219
228
ret .add (negationPropExpr );
@@ -278,7 +287,6 @@ private Collection<OWLClassExpression> createConceptFromExpression(OWLClassExpre
278
287
}
279
288
280
289
281
-
282
290
private Collection <OWLObjectPropertyExpression > getRangePropertiesForClass (OWLClass owlClass ) {
283
291
Collection <OWLObjectPropertyExpression > ret = new ArrayList <>();
284
292
getAxiomsForClass (owlClass ).forEach (axiom -> {
0 commit comments