use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method negations_ignored.
@Test
public void negations_ignored() throws IOException {
define_standard_schema("basic-schema");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match" + " $p isa person;" + " not {$p isa man;};";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$p", set("person", "man", "woman"));
put("$_person", set("person"));
}
};
assertEquals(expected, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method has_inference_variable_without_attribute_type.
@Test
public void has_inference_variable_without_attribute_type() throws IOException {
define_standard_schema("basic-schema");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match" + " $p isa shape;" + " $p has $a;";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$p", set("triangle", "right-angled-triangle", "square"));
put("$a", set("perimeter", "area", "label", "hypotenuse-length"));
put("$_shape", set("shape"));
}
};
assertEquals(expected, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method infer_key_attributes.
@Test
public void infer_key_attributes() {
define_custom_schema("define" + " person sub entity, owns name @key;" + " name sub attribute, value string;");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match $x has name 'bob';";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$x", set("person"));
put("$_0", set("name"));
put("$_name", set("name"));
}
};
assertEquals(expected, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method relation_variable_role_concrete_relation_hidden_variable.
@Test
public void relation_variable_role_concrete_relation_hidden_variable() throws IOException {
define_standard_schema("basic-schema");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match $r ($role: $yoko) isa marriage;";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$yoko", set("person", "man", "woman"));
put("$role", set("marriage:husband", "marriage:wife", "marriage:spouse", "relation:role"));
put("$r", set("marriage"));
put("$_marriage", set("marriage"));
}
};
assertEquals(expected, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class CompletenessVerifier method numReasonedAnswers.
private int numReasonedAnswers(BoundConjunction boundConjunction, Set<Identifier.Variable.Retrievable> filter) {
try (CoreTransaction tx = session.transaction(Arguments.Transaction.Type.READ, new Options.Transaction().infer(true))) {
Disjunction disjunction = new Disjunction(Collections.singletonList(boundConjunction.conjunction()));
tx.logic().typeInference().applyCombination(disjunction);
return tx.reasoner().executeReasoner(disjunction, filter, new Context.Query(tx.context(), new Options.Query())).toList().size();
}
}
Aggregations