use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasoningTests method relationTypesAreCorrectlyInferredInConjunction_TypeArePresent.
// Expected result: no answers (if types were incorrectly inferred the query would yield answers)
@Test
public void relationTypesAreCorrectlyInferredInConjunction_TypeArePresent() {
QueryBuilder qb = testSet28.tx().graql().infer(true);
String queryString = "match " + "(role1: $x, role2: $y) isa relation1;" + "(role1: $y, role2: $z) isa relation1;" + "(role3: $z, role4: $w) isa relation3; get;";
assertThat(qb.<GetQuery>parse(queryString).execute(), empty());
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasoningTests method generatingFreshEntity.
// TODO: currently disallowed by rule validation
@Ignore
// Expected result: The queries should return different matches, unique per query.
@Test
public void generatingFreshEntity() {
QueryBuilder qb = testSet3.tx().graql().infer(true);
String queryString = "match $x isa entity1; get;";
String queryString2 = "match $x isa entity2; get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
List<Answer> answers2 = qb.<GetQuery>parse(queryString2).execute();
assertEquals(answers.size(), answers2.size());
assertFalse(answers.containsAll(answers2));
assertFalse(answers2.containsAll(answers));
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasoningTests method circularRuleDependencies.
// Expected result: The query should return two unique matches
@Test
public void circularRuleDependencies() {
QueryBuilder qb = testSet12.tx().graql().infer(true);
String queryString = "match (role1:$x, role2:$y) isa relation3; get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
assertEquals(answers.size(), 2);
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasoningTests method roleUnificationWithRoleHierarchiesInvolved.
// Expected result: The query should not return any matches (or possibly return a single match with $x=$y)
@Test
public void roleUnificationWithRoleHierarchiesInvolved() {
QueryBuilder qb = testSet8.tx().graql().infer(true);
String queryString = "match (role2:$x, role3:$y) isa relation2; get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
assertThat(answers.stream().collect(toSet()), empty());
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class ReasoningTests method instanceTypeHierarchyRespected_queryHasSuperTypes_recursiveRule.
// Expected result: Two answers obtained only if the rule query containing sub type is correctly executed.
@Test
public void instanceTypeHierarchyRespected_queryHasSuperTypes_recursiveRule() {
QueryBuilder qb = testSet19recursive.tx().graql().infer(true);
String queryString = "match " + "$x isa entity1;" + "$y isa entity1;" + "(role1: $x, role2: $y) isa relation1;";
String queryString2 = queryString + "$y has name 'a';";
List<Answer> answers = qb.<GetQuery>parse(queryString + " get;").execute();
assertEquals(answers.size(), 2);
List<Answer> answers2 = qb.<GetQuery>parse(queryString2 + " get;").execute();
assertEquals(answers2.size(), 2);
}
Aggregations