diff options
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredTypeRefiner.java')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredTypeRefiner.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredTypeRefiner.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredTypeRefiner.java new file mode 100644 index 00000000..40a7b3fa --- /dev/null +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredTypeRefiner.java | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.reasoning.translator.typehierarchy; | ||
7 | |||
8 | import tools.refinery.store.model.Interpretation; | ||
9 | import tools.refinery.store.reasoning.ReasoningAdapter; | ||
10 | import tools.refinery.store.reasoning.refinement.AbstractPartialInterpretationRefiner; | ||
11 | import tools.refinery.store.reasoning.representation.PartialSymbol; | ||
12 | import tools.refinery.store.representation.Symbol; | ||
13 | import tools.refinery.store.representation.TruthValue; | ||
14 | import tools.refinery.store.tuple.Tuple; | ||
15 | |||
16 | class InferredTypeRefiner extends AbstractPartialInterpretationRefiner<TruthValue, Boolean> { | ||
17 | private final Interpretation<InferredType> interpretation; | ||
18 | private final TypeAnalysisResult result; | ||
19 | |||
20 | private InferredTypeRefiner(ReasoningAdapter adapter, PartialSymbol<TruthValue, Boolean> partialSymbol, | ||
21 | Symbol<InferredType> symbol, TypeAnalysisResult result) { | ||
22 | super(adapter, partialSymbol); | ||
23 | interpretation = adapter.getModel().getInterpretation(symbol); | ||
24 | this.result = result; | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public boolean merge(Tuple key, TruthValue value) { | ||
29 | var currentType = interpretation.get(key); | ||
30 | var newType = result.merge(currentType, value); | ||
31 | interpretation.put(key, newType); | ||
32 | return true; | ||
33 | } | ||
34 | |||
35 | public static Factory<TruthValue, Boolean> of(Symbol<InferredType> symbol, TypeAnalysisResult result) { | ||
36 | return (adapter, partialSymbol) -> new InferredTypeRefiner(adapter, partialSymbol, symbol, result); | ||
37 | } | ||
38 | } | ||