use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method role_labels_reduced_by_full_type_resolver.
@Test
public void role_labels_reduced_by_full_type_resolver() {
define_custom_schema("define" + " person sub entity, plays partnership:partner;" + " partnership sub relation, relates partner;" + " business sub relation, relates partner;");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match (partner: $x);";
Disjunction disjunction = createDisjunction(queryString);
Conjunction conjunction = disjunction.conjunctions().get(0);
typeInference.applyCombination(conjunction, false);
Set<String> expectedResolvedTypes = set("partnership:partner");
assertEquals(expectedResolvedTypes, resolvedTypeMap(disjunction.conjunctions().get(0)).get("$_relation:partner"));
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method is_inference.
@Test
public void is_inference() throws IOException {
define_standard_schema("basic-schema");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match" + " $p isa entity;" + " $p is $q;" + " $q isa mammal;";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expectedExhaustive = new HashMap<>() {
{
put("$p", set("mammal", "person", "man", "woman", "dog"));
put("$q", set("mammal", "person", "man", "woman", "dog"));
put("$_entity", set("entity"));
put("$_mammal", set("mammal"));
}
};
assertEquals(expectedExhaustive, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
use of com.vaticle.typedb.core.pattern.Disjunction in project grakn by graknlabs.
the class TypeInferenceTest method isa_explicit_inference.
@Test
public void isa_explicit_inference() throws IOException {
define_standard_schema("basic-schema");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match $p isa! person; ";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$p", set("person"));
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 relation_concrete_role_concrete.
@Test
public void relation_concrete_role_concrete() throws IOException {
define_standard_schema("basic-schema");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match $r (wife: $yoko) isa marriage;";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$yoko", set("woman"));
put("$r", set("marriage"));
put("$_marriage:wife", set("marriage:wife"));
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 TypeInferenceTest method infers_value_cycle.
@Test
public void infers_value_cycle() throws IOException {
define_custom_schema("define" + " person sub entity, owns name, owns height;" + " name sub attribute, value string, owns nickname, owns height;" + " nickname sub attribute, value string, owns name;" + " surname sub attribute, value string, owns name;" + " name sub attribute, value string;" + " surname sub attribute, value string;" + " nickname sub attribute, value string;" + " height sub attribute, value double, owns weight, owns name;" + " weight sub attribute, value double, owns height;" + " ");
TypeInference typeInference = transaction.logic().typeInference();
String queryString = "match " + " $x = 'bob';" + " $y = $x;" + " $x has $y;" + " $y has $x;";
Disjunction disjunction = createDisjunction(queryString);
typeInference.applyCombination(disjunction);
Map<String, Set<String>> expected = new HashMap<>() {
{
put("$x", set("nickname", "name"));
put("$y", set("nickname", "name"));
}
};
assertEquals(expected, resolvedTypeMap(disjunction.conjunctions().get(0)));
}
Aggregations