Skip to content

Commit

Permalink
RYA-292 PR Update #4
Browse files Browse the repository at this point in the history
  • Loading branch information
ejwhite922 committed Aug 22, 2017
1 parent 062bc68 commit 8b687cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
Expand Up @@ -267,7 +267,7 @@ public void refreshGraph() throws InferenceEngineException {
// query for the list of indexed properties
iter = RyaDAOHelper.query(ryaDAO, bNode, vf.createURI("http://www.w3.org/2000/10/swap/list#index"),
null, conf);
final TreeMap<Integer, URI> orderedProperties = new TreeMap<Integer, URI>();
final TreeMap<Integer, URI> orderedProperties = new TreeMap<>();
// TODO refactor this. Wish I could execute sparql
try {
while (iter.hasNext()){
Expand Down Expand Up @@ -324,7 +324,7 @@ public void refreshGraph() throws InferenceEngineException {
iter.close();
}
}
final List<URI> properties = new ArrayList<URI>();
final List<URI> properties = new ArrayList<>();
for (final Map.Entry<Integer, URI> entry : orderedProperties.entrySet()){
properties.add(entry.getValue());
}
Expand All @@ -339,7 +339,7 @@ public void refreshGraph() throws InferenceEngineException {

CloseableIteration<Statement, QueryEvaluationException> iter2 = RyaDAOHelper.query(ryaDAO, propertyChainPropertiesToBNodes.get(propertyChainProperty), RDF.FIRST,
null, conf);
final List<URI> properties = new ArrayList<URI>();
final List<URI> properties = new ArrayList<>();
URI previousBNode = propertyChainPropertiesToBNodes.get(propertyChainProperty);
if (iter2.hasNext()) {
Statement iter2Statement = iter2.next();
Expand Down Expand Up @@ -753,20 +753,12 @@ public void handleStatement(final Statement statement) throws RDFHandlerExceptio
otherKeys.remove(type);
for (final Resource otherKey : otherKeys) {
if (intersectionsProp.get(otherKey).contains(intersection)) {
for (final URI superClass : superClasses) {
addSubClassOf(otherKey, superClass);
}
addSubClassOf(otherKey, type);
addSubClassOf(type, otherKey);
}
}
}
}
for (final Entry<Resource, List<Set<Resource>>> entry : intersectionsProp.entrySet()) {
final Resource type = entry.getKey();
final List<Set<Resource>> intersectionList = entry.getValue();
for (final Set<Resource> intersection : intersectionList) {
addIntersection(intersection, type);
}
}
}

/**
Expand Down Expand Up @@ -961,7 +953,7 @@ public Set<Statement> findTransitiveProperty(final Resource subj, final URI prop
* TODO: This chaining can be slow at query execution. the other option is to perform this in the query itself, but that will be constrained to how many levels we decide to go
*/
public Set<Resource> findSameAs(final Resource value, final Resource... contxts) throws InferenceEngineException{
final Set<Resource> sameAs = new HashSet<Resource>();
final Set<Resource> sameAs = new HashSet<>();
sameAs.add(value);
findSameAsChaining(value, sameAs, contxts);
return sameAs;
Expand Down
Expand Up @@ -406,14 +406,17 @@ public void testIntersectionOf() throws Exception {
Assert.assertEquals(intersectionsImplyingFather, inferenceEngine.getIntersectionsImplying(father));

// Check that Mother is a subclassOf Parent and Woman and
// ImmediateFamilyMember and Relative
// ImmediateFamilyMember and Relative. Also, Mother is a subclassOf
// Mother and Mom through inferring equivalentClass.
final Set<URI> motherSuperClassUris = inferenceEngine.getSuperClasses(mother);
Assert.assertNotNull(motherSuperClassUris);
Assert.assertEquals(4, motherSuperClassUris.size());
Assert.assertEquals(6, motherSuperClassUris.size());
Assert.assertTrue(motherSuperClassUris.contains(parent));
Assert.assertTrue(motherSuperClassUris.contains(woman));
Assert.assertTrue(motherSuperClassUris.contains(immediateFamilyMember));
Assert.assertTrue(motherSuperClassUris.contains(relative));
Assert.assertTrue(motherSuperClassUris.contains(mother));
Assert.assertTrue(motherSuperClassUris.contains(mom));
// Check that Father is a subclassOf Parent and Man
final Set<URI> fatherSuperClassUris = inferenceEngine.getSuperClasses(father);
Assert.assertNotNull(fatherSuperClassUris);
Expand All @@ -423,13 +426,16 @@ public void testIntersectionOf() throws Exception {

// Check that Mom is a subclassOf Parent and Woman and
// ImmediateFamilyMember and Relative. The last 2 should be inferred
// from having the same intersection as Mother.
// from having the same intersection as Mother. Also, Mom is a
// subclassOf Mother and Mom through inferring equivalentClass.
final Set<URI> momSuperClassUris = inferenceEngine.getSuperClasses(mom);
Assert.assertNotNull(momSuperClassUris);
Assert.assertEquals(4, momSuperClassUris.size());
Assert.assertEquals(6, momSuperClassUris.size());
Assert.assertTrue(momSuperClassUris.contains(parent));
Assert.assertTrue(momSuperClassUris.contains(woman));
Assert.assertTrue(momSuperClassUris.contains(immediateFamilyMember));
Assert.assertTrue(momSuperClassUris.contains(relative));
Assert.assertTrue(momSuperClassUris.contains(mother));
Assert.assertTrue(momSuperClassUris.contains(mom));
}
}

0 comments on commit 8b687cf

Please sign in to comment.