use of fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty 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.property.RuleSetProperty in project graal by graphik-team.
the class RuleSetPropertyHierarchy method setProperties.
public void setProperties(Iterable<RuleSetProperty> pties) {
this.properties = new ArrayList<RuleSetProperty>();
this.propertyIndex = new TreeMap<String, Integer>();
this.currentPtyIndex = 0;
for (RuleSetProperty p : pties) {
if (this.propertyIndex.get(p.getLabel()) == null) {
this.propertyIndex.put(p.getLabel(), new Integer(this.currentPtyIndex++));
this.properties.add(p);
}
}
this.specialisations = new boolean[this.currentPtyIndex][this.currentPtyIndex];
this.computeSpecialisations();
}
use of fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty in project graal by graphik-team.
the class RuleSetPropertyHierarchy method computeSpecialisations.
private void computeSpecialisations() {
for (int i = 0; i < this.currentPtyIndex; ++i) for (int j = 0; j < this.currentPtyIndex; ++j) this.specialisations[i][j] = false;
int id0, id1;
for (RuleSetProperty p : this.properties) {
id0 = this.propertyIndex.get(p.getLabel()).intValue();
for (RuleSetProperty p2 : p.getGeneralisations()) {
if (this.propertyIndex.get(p2.getLabel()) != null) {
id1 = this.propertyIndex.get(p2.getLabel()).intValue();
this.specialisations[id0][id1] = true;
}
}
for (RuleSetProperty p2 : p.getSpecialisations()) {
if (this.propertyIndex.get(p2.getLabel()) != null) {
id1 = this.propertyIndex.get(p2.getLabel()).intValue();
this.specialisations[id1][id0] = true;
}
}
}
this.computeSpecialisationClosure();
}
use of fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty in project graal by graphik-team.
the class Analyser method computeProperties.
protected Map<String, Integer> computeProperties(AnalyserRuleSet set) {
Map<String, Integer> result = new TreeMap<String, Integer>();
Iterable<RuleSetProperty> pties = this.hierarchy.getOrderedProperties();
int res;
for (RuleSetProperty p : pties) {
if (result.get(p.getLabel()) == null) {
res = p.check(set);
result.put(p.getLabel(), Integer.valueOf(res));
if (res > 0) {
for (RuleSetProperty p2 : this.hierarchy.getGeneralisationsOf(p)) result.put(p2.getLabel(), Integer.valueOf(res));
}
}
}
return result;
}
Aggregations