use of fr.lirmm.graphik.graal.core.TreeMapSubstitution in project graal by graphik-team.
the class Utils method getSafeCopy.
public static InMemoryAtomSet getSafeCopy(InMemoryAtomSet atomSet) {
Substitution substitution = new TreeMapSubstitution();
for (Variable t : atomSet.getVariables()) {
substitution.put(t, varGen.getFreshSymbol());
}
InMemoryAtomSet safe = new LinkedListAtomSet();
substitution.apply(atomSet, safe);
return safe;
}
use of fr.lirmm.graphik.graal.core.TreeMapSubstitution in project graal by graphik-team.
the class IDCompilation method homomorphism.
@Override
public LinkedList<Substitution> homomorphism(Atom father, Atom son) {
LinkedList<Substitution> res = new LinkedList<Substitution>();
Predicate predB = son.getPredicate();
Predicate predH = father.getPredicate();
List<IDCondition> conds = getConditions(predB, predH);
for (IDCondition cond : conds) {
if (cond.checkBody(son.getTerms())) {
Substitution homo = cond.homomorphism(father.getTerms(), son.getTerms());
if (homo != null) {
res.add(new TreeMapSubstitution(homo));
}
}
}
return res;
}
use of fr.lirmm.graphik.graal.core.TreeMapSubstitution in project graal by graphik-team.
the class Utils method getSafeCopy.
public static Rule getSafeCopy(Rule rule) {
Substitution substitution = new TreeMapSubstitution();
for (Variable t : rule.getVariables()) {
substitution.put(t, varGen.getFreshSymbol());
}
InMemoryAtomSet body = rule.getBody();
InMemoryAtomSet head = rule.getHead();
InMemoryAtomSet safeBody = new LinkedListAtomSet();
InMemoryAtomSet safeHead = new LinkedListAtomSet();
substitution.apply(body, safeBody);
substitution.apply(head, safeHead);
return DefaultRuleFactory.instance().create(safeBody, safeHead);
}
use of fr.lirmm.graphik.graal.core.TreeMapSubstitution in project graal by graphik-team.
the class ResultSet2SubstitutionConverter method convert.
// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public Substitution convert(ResultSet result) throws ConversionException {
try {
Substitution substitution = new TreeMapSubstitution();
if (!ans.isEmpty()) {
for (Term t : ans) {
if (t.isVariable()) {
int i = result.findColumn(t.getLabel());
int type = result.getMetaData().getColumnType(i);
String value = result.getString(i);
Term substitut = this.queryTranslator.createTermFromColumnType(type, value);
substitution.put((Variable) t, substitut);
}
}
}
return substitution;
} catch (SQLException e) {
throw new ConversionException(e);
} catch (AtomSetException e) {
throw new ConversionException(e);
}
}
Aggregations