use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class SNBInferenceTest method testVarConsistency3.
@Test
public void testVarConsistency3() {
QueryBuilder qb = snbGraph.tx().graql().infer(false);
QueryBuilder iqb = snbGraph.tx().graql().infer(true);
String queryString = "match $x isa person;$pr isa product, has name 'Nocturnes';($x, $pr) isa recommendation; get $x;";
String explicitQuery = "match {$x has name 'Frank';} or {$x has name 'Karl Fischer';}; get $x;";
assertQueriesEqual(iqb.materialise(false).parse(queryString), qb.parse(explicitQuery));
assertQueriesEqual(iqb.materialise(true).parse(queryString), qb.parse(explicitQuery));
}
use of ai.grakn.graql.QueryBuilder 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.QueryBuilder 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.QueryBuilder 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.QueryBuilder 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());
}
Aggregations