use of fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet in project graal by graphik-team.
the class DefaultKnowledgeBase method analyse.
protected void analyse() {
if (!this.isAnalysed) {
this.analysedRuleSet = new AnalyserRuleSet(this.ruleset);
Map<String, RuleSetProperty> properties = new HashMap<>();
if (this.approach != Approach.REWRITING_ONLY) {
properties.putAll(RuleSetPropertyHierarchy.generatePropertyMapSpecializationOf(FESProperty.instance()));
}
if (this.approach != Approach.SATURATION_ONLY) {
properties.putAll(RuleSetPropertyHierarchy.generatePropertyMapSpecializationOf(FUSProperty.instance()));
}
this.analyse = new Analyser(analysedRuleSet);
this.analyse.setProperties(properties.values());
this.isAnalysed = true;
}
}
use of fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet in project graal by graphik-team.
the class Analyser method ruleProperties.
public List<Map<String, Integer>> ruleProperties() {
if (this.ruleProperties == null) {
this.ruleProperties = new LinkedList<Map<String, Integer>>();
for (Rule r : this.ruleSet) {
AnalyserRuleSet subAnalyser = new AnalyserRuleSet(r);
this.ruleProperties.add(computeProperties(subAnalyser));
}
}
return this.ruleProperties;
}
use of fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet in project graal by graphik-team.
the class MFAProperty method check.
/**
*/
@Override
public int check(AnalyserRuleSet ruleSet) {
RuleSet R = translateToMFA(ruleSet);
AtomSet A = Rules.criticalInstance(ruleSet);
Chase chase = new ChaseWithGRD<AtomSet>(new DefaultGraphOfRuleDependencies(R), A, new DefaultRuleApplier<AtomSet>(new FrontierRestrictedChaseHaltingCondition()));
DefaultConjunctiveQuery Q = new DefaultConjunctiveQuery();
DefaultAtom q = new DefaultAtom(C);
q.setTerm(0, FAKE);
Q.getAtomSet().add(q);
try {
while (chase.hasNext()) {
chase.next();
if (SmartHomomorphism.instance().exist(Q, A)) {
return -1;
}
}
} catch (ChaseException e) {
LOGGER.warn("An error occurs during the chase: ", e);
return 0;
} catch (HomomorphismException e) {
LOGGER.warn("An error occurs during the homomorphism: ", e);
return 0;
}
return 1;
}
use of fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet in project graal by graphik-team.
the class MSAProperty method check.
@Override
public int check(AnalyserRuleSet ruleSet) {
RuleSet R = translateToMSA(ruleSet);
AtomSet A = Rules.criticalInstance(ruleSet);
try {
StaticChase.executeChase(A, R);
} catch (ChaseException e) {
LOGGER.warn("An error occurs during the chase: ", e);
return 0;
}
DefaultConjunctiveQuery Q = new DefaultConjunctiveQuery();
DefaultAtom q = new DefaultAtom(C);
q.setTerm(0, FAKE);
Q.getAtomSet().add(q);
try {
if (SmartHomomorphism.instance().exist(Q, A))
return -1;
return 1;
} catch (HomomorphismException e) {
LOGGER.warn("An error occurs during the homomorphism: ", e);
return 0;
}
}
Aggregations