use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class AdmissionsInferenceTest method testAdmissions.
@Test
public void testAdmissions() {
QueryBuilder qb = admissionsKB.tx().graql().infer(false);
QueryBuilder iqb = admissionsKB.tx().graql().infer(true);
String queryString = "match $x has admissionStatus $y;$x has name $name; get;";
assertQueriesEqual(iqb.materialise(false).parse(queryString), qb.parse(queryString));
assertQueriesEqual(iqb.materialise(true).parse(queryString), qb.parse(queryString));
}
use of ai.grakn.graql.QueryBuilder in project grakn by graknlabs.
the class RecursiveInferenceTest method testDualLinearTransitivityMatrix.
/**
* test 6.1 from Cao p 71
*/
@Test
public void testDualLinearTransitivityMatrix() {
final int N = 5;
SampleKBContext kb = DualLinearTransitivityMatrixKB.context(N, N);
QueryBuilder qb = kb.tx().graql().infer(false);
QueryBuilder iqb = kb.tx().graql().infer(true);
String queryString = "match (Q1-from: $x, Q1-to: $y) isa Q1; $x has index 'a0'; get $y;";
String explicitQuery = "match $y isa a-entity or $y isa end; get;";
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 RecursiveInferenceTest method testAncestorPrime.
/**
*as above but both directions
*/
@Test
public void testAncestorPrime() {
QueryBuilder qb = ancestorContext.tx().graql().infer(false);
QueryBuilder iqb = ancestorContext.tx().graql().infer(true);
String queryString = "match ($X, $Y) isa Ancestor;$X has name 'aa'; get $Y;";
String explicitQuery = "match $Y isa person, has name $name;" + "{$name val 'a';} or {$name val 'aaa';} or {$name val 'aab';} or {$name val 'aaaa';};get $Y;";
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 RecursiveInferenceTest method testAncestorFriendPrime.
/**
*from Vieille - Recursive Axioms in Deductive Databases (QSQ approach) p. 186
*/
@Test
public void testAncestorFriendPrime() {
QueryBuilder qb = ancestorFriendContext.tx().graql().infer(false);
QueryBuilder iqb = ancestorFriendContext.tx().graql().infer(true);
String queryString = "match ($X, $Y) isa Ancestor-friend;$X has name 'a'; get $Y;";
String explicitQuery = "match $Y has name $name;{$name val 'd';} or {$name val 'g';}; get $Y;";
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 RecursiveInferenceTest method testReverseSameGeneration2.
@Test
public void testReverseSameGeneration2() {
QueryBuilder qb = recursivityRSGContext.tx().graql().infer(false);
QueryBuilder iqb = recursivityRSGContext.tx().graql().infer(true);
String queryString = "match (RSG-from: $x, RSG-to: $y) isa RevSG; get;";
String explicitQuery = "match $x has name $nameX;$y has name $nameY;" + "{$nameX val 'a';$nameY val 'b';} or {$nameX val 'a';$nameY val 'c';} or" + "{$nameX val 'a';$nameY val 'd';} or {$nameX val 'm';$nameY val 'n';} or" + "{$nameX val 'm';$nameY val 'o';} or {$nameX val 'p';$nameY val 'm';} or" + "{$nameX val 'g';$nameY val 'f';} or {$nameX val 'h';$nameY val 'f';} or" + "{$nameX val 'i';$nameY val 'f';} or {$nameX val 'j';$nameY val 'f';} or" + "{$nameX val 'f';$nameY val 'k';};get $x, $y;";
assertQueriesEqual(iqb.materialise(false).parse(queryString), qb.parse(explicitQuery));
assertQueriesEqual(iqb.materialise(true).parse(queryString), qb.parse(explicitQuery));
}
Aggregations