use of ai.grakn.graql.admin.Answer in project grakn by graknlabs.
the class ReasoningTests method reusingResources_definingResourceThroughOtherResourceWithConditionalValue.
// Expected result: When the head of a rule contains resource assertions, the respective unique resources should be generated or reused.
@Test
public void reusingResources_definingResourceThroughOtherResourceWithConditionalValue() {
QueryBuilder qb = testSet15.tx().graql().infer(true);
String queryString = "match $x has boolean-resource $r; get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
assertEquals(answers.size(), 1);
}
use of ai.grakn.graql.admin.Answer in project grakn by graknlabs.
the class ReasoningTests method reasoningWithRepeatingRoles.
// Expected result: Returns db and inferred relations + their inverses and relations with self for all entities
@Test
public void reasoningWithRepeatingRoles() {
QueryBuilder qb = testSet22.tx().graql().infer(true);
String queryString = "match (friend:$x1, friend:$x2) isa knows-trans; get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
assertEquals(answers.size(), 16);
}
use of ai.grakn.graql.admin.Answer in project grakn by graknlabs.
the class ReasoningTests method whenReasoningWithResourcesWithRelationVar_ResultsAreComplete.
@Test
public void whenReasoningWithResourcesWithRelationVar_ResultsAreComplete() {
QueryBuilder qb = testSet14.tx().graql().infer(true);
VarPattern has = var("x").has(Label.of("resource"), var("y"), var("r"));
List<Answer> answers = qb.match(has).get().execute();
assertEquals(answers.size(), 3);
answers.forEach(a -> assertTrue(a.vars().contains(var("r"))));
}
use of ai.grakn.graql.admin.Answer in project grakn by graknlabs.
the class ReasoningTests method roleUnificationWithRepeatingRoleTypes.
// Expected result: The query should not return any matches (or possibly return a single match with $x=$y)
@Test
public void roleUnificationWithRepeatingRoleTypes() {
QueryBuilder qb = testSet9.tx().graql().infer(true);
String queryString = "match (role1:$x, role1:$y) isa relation2; get;";
List<Answer> answers = qb.<GetQuery>parse(queryString).execute();
assertThat(answers.stream().collect(toSet()), empty());
}
use of ai.grakn.graql.admin.Answer 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));
}
Aggregations