Skip to content

Commit

Permalink
clarification
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin SEJOURNE committed Nov 19, 2017
1 parent 4d6f09b commit 32b5d6c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
17 changes: 7 additions & 10 deletions module-core/src/main/java/openllet/core/KnowledgeBaseImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3060,7 +3060,7 @@ public boolean hasInstance(final ATerm d)
unknowns.add(x);
}

final boolean hasInstance = !unknowns.isEmpty() && _abox.isType(unknowns, c);
final boolean hasInstance = !unknowns.isEmpty() && _abox.existType(unknowns, c);

return hasInstance;
}
Expand Down Expand Up @@ -4580,7 +4580,7 @@ public Set<ATermAppl> retrieve(final ATermAppl d, final Collection<ATermAppl> in
if (OpenlletOptions.INSTANCE_RETRIEVAL == InstanceRetrievalMethod.TRACING_BASED && OpenlletOptions.USE_TRACING)
tracingBasedInstanceRetrieval(c, unknowns, knowns);
else
if (_abox.isType(unknowns, c))
if (_abox.existType(unknowns, c))
if (OpenlletOptions.INSTANCE_RETRIEVAL == InstanceRetrievalMethod.BINARY)
binaryInstanceRetrieval(c, unknowns, knowns);
else
Expand Down Expand Up @@ -4634,7 +4634,7 @@ public void tracingBasedInstanceRetrieval(final ATermAppl c, final List<ATermApp
setDoExplanation(true);

final ATermAppl notC = ATermUtils.negate(c);
while (_abox.isType(individuals, c))
while (_abox.existType(individuals, c))
{
final Set<ATermAppl> explanationSet = getExplanationSet();

Expand Down Expand Up @@ -4676,10 +4676,7 @@ public void binaryInstanceRetrieval(final ATermAppl c, final List<ATermAppl> can
if (candidates.isEmpty())
return;
else
{
final List<ATermAppl>[] partitions = partition(candidates);
partitionInstanceRetrieval(c, partitions, results);
}
partitionInstanceRetrieval(c, partition(candidates), results);
}

private void partitionInstanceRetrieval(final ATermAppl c, final List<ATermAppl>[] partitions, final Collection<ATermAppl> results)
Expand All @@ -4693,10 +4690,10 @@ private void partitionInstanceRetrieval(final ATermAppl c, final List<ATermAppl>
results.add(i);
}
else
if (!_abox.isType(partitions[0], c))
if (!_abox.existType(partitions[0], c))
binaryInstanceRetrieval(c, partitions[1], results);
else
if (!_abox.isType(partitions[1], c))
if (!_abox.existType(partitions[1], c))
binaryInstanceRetrieval(c, partitions[0], results);
else
{
Expand All @@ -4713,7 +4710,7 @@ private static List<ATermAppl>[] partition(final List<ATermAppl> candidates)
if (n <= 1)
{
partitions[0] = candidates;
partitions[1] = new ArrayList<>();
partitions[1] = Collections.emptyList();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public interface ABox extends Logging
* @param inds
* @return true if any of the individuals in the given list belongs to type c.
*/
public boolean isType(final List<ATermAppl> inds, ATermAppl c);
public boolean existType(final List<ATermAppl> inds, ATermAppl c);

public Bool hasObviousPropertyValue(final ATermAppl s, final ATermAppl p, final ATermAppl o);

Expand Down
20 changes: 10 additions & 10 deletions module-core/src/main/java/openllet/core/boxes/abox/ABoxImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ public boolean isType(final ATermAppl x, final ATermAppl cParam)

final Optional<Timer> timer = _kb.getTimers().startTimer("isType");
final boolean isType = !isConsistent(SetUtils.singleton(x), notC, false);
timer.ifPresent(t -> t.stop());
timer.ifPresent(Timer::stop);

if (_logger.isLoggable(Level.FINE))
_logger.fine("Type " + isType + " " + ATermUtils.toString(c) + " for individual " + ATermUtils.toString(x));
Expand All @@ -894,7 +894,7 @@ public boolean isType(final ATermAppl x, final ATermAppl cParam)
}

@Override
public boolean isType(final List<ATermAppl> inds, final ATermAppl cParam)
public boolean existType(final List<ATermAppl> inds, final ATermAppl cParam)
{
final ATermAppl c = ATermUtils.normalize(cParam);

Expand Down Expand Up @@ -1328,22 +1328,22 @@ private boolean checkAssertedClashes()
}

/**
* Check the consistency of this ABox possibly after adding some type assertions. If <code>c</code> is null then nothing is added to ABox (pure consistency
* test) and the individuals should be an empty collection. If <code>c</code> is not null but <code>individuals</code> is empty, this is a satisfiability
* check for concept <code>c</code> so a new individual will be added with type <code>c</code>. If individuals is not empty, this means we will add type
* <code>c</code> to each of the individuals in the collection and check the consistency.
* Check the consistency of this ABox possibly after adding some type assertions. If <code>c_</code> is null then nothing is added to ABox (pure consistency
* test) and the individuals should be an empty collection. If <code>c_</code> is not null but <code>individuals</code> is empty, this is a satisfiability
* check for concept <code>c_</code> so a new individual will be added with type <code>c_</code>. If individuals is not empty, this means we will add type
* <code>c_</code> to each of the individuals in the collection and check the consistency.
* <p>
* The consistency checks will be done either on a copy of the ABox or its pseudo model depending on the situation. In either case this ABox will not be
* modified at all. After the consistency check _lastCompletion points to the modified ABox.
* modified at all. After the consistency check lastCompletion points to the modified ABox.
*
* @param individuals
* @param cParam
* @param c_
* @return true if consistent.
*/
private boolean isConsistent(final Collection<ATermAppl> individualsParam, final ATermAppl cParam, final boolean cacheModel)
private boolean isConsistent(final Collection<ATermAppl> individualsParam, final ATermAppl c_, final boolean cacheModel)
{
Collection<ATermAppl> individuals = individualsParam;
ATermAppl c = cParam;
ATermAppl c = c_;

final Optional<Timer> timer = _kb.getTimers().startTimer("isConsistent");

Expand Down
2 changes: 1 addition & 1 deletion module-core/src/main/java/openllet/core/utils/Timers.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public <RESULT> RESULT execute(final String name, final Supplier<RESULT> produce
}
finally
{
timer.ifPresent(t -> t.stop());
timer.ifPresent(Timer::stop);
}
}

Expand Down

0 comments on commit 32b5d6c

Please sign in to comment.