Introduce method isBasis to Rule class, use that for feedback

Feedback basis are calculated for rules in history that
are marked as "basis" instead of "principal".
This commit is contained in:
Fedor Isakov 2021-04-12 12:13:32 +02:00
parent 87a843088c
commit 0cef5ad298
4 changed files with 7 additions and 5 deletions

View File

@ -175,7 +175,7 @@ internal class ControllerImpl (
if (status.feedback?.alreadyHandled() == false) {
status.feedback.handle(match,
newParent.match.feedbackKey,
processing.principalRuleTags(newParent),
processing.basisRuleTags(newParent),
supervisor)
}
}
@ -199,7 +199,7 @@ internal class ControllerImpl (
} else if (status.feedback?.alreadyHandled() == false
&& status.failure.handle(match,
newParent.match.feedbackKey,
processing.principalRuleTags(newParent),
processing.basisRuleTags(newParent),
supervisor)) {
status.recover()

View File

@ -121,7 +121,7 @@ interface MatchJournal : EvidenceSource {
*/
fun index(): Index
fun principalRuleTags(chunk: Chunk): List<Any>
fun basisRuleTags(chunk: Chunk): List<Any>
/**
* Simplifies some search operations on [MatchJournal].

View File

@ -243,12 +243,12 @@ internal open class MatchJournalImpl(
override fun index(): MatchJournal.Index = IndexImpl(hist)
override fun principalRuleTags(chunk: Chunk): List<Any> {
override fun basisRuleTags(chunk: Chunk): List<Any> {
val ptags = mutableListOf<Any>()
chunk.justifications().forEach { jn ->
// hist is sequential, random access can be expensive
(lookupChunkByEvidence(jn) as? MatchChunk)?.let {
if (it.match.isPrincipal) {
if (it.match.rule().isBasis) {
ptags.add(it.ruleUniqueTag)
}
}

View File

@ -40,6 +40,8 @@ public abstract class Rule {
return Collections.emptyList();
}
public boolean isBasis() { return false; }
/**
* A tag uniquely identifies the rule.
*/