Search in sources :

Example 1 with RuleSetProperty

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;
    }
}
Also used : HashMap(java.util.HashMap) Analyser(fr.lirmm.graphik.graal.rulesetanalyser.Analyser) RuleSetProperty(fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty) AnalyserRuleSet(fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet)

Example 2 with RuleSetProperty

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();
}
Also used : RuleSetProperty(fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty)

Example 3 with RuleSetProperty

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();
}
Also used : RuleSetProperty(fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty)

Example 4 with RuleSetProperty

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;
}
Also used : RuleSetProperty(fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty) TreeMap(java.util.TreeMap)

Aggregations

RuleSetProperty (fr.lirmm.graphik.graal.rulesetanalyser.property.RuleSetProperty)4 Analyser (fr.lirmm.graphik.graal.rulesetanalyser.Analyser)1 AnalyserRuleSet (fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1