use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryWithNoRelationTypeWithRoles.
@Test
public void testReasoningWithQueryWithNoRelationTypeWithRoles() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match $x isa city;$y isa country;(geo-entity: $x, $y);$y has name 'Poland'; get;";
String queryString2 = "match $x isa city;$y isa country;" + "(geo-entity: $x, entity-location: $y) isa is-located-in;$y has name 'Poland'; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryContainingPlays2.
@Test
public void testReasoningWithQueryContainingPlays2() {
String queryString = "match $x isa person;$y isa $type;$type plays recommended-product;($x, $y) isa recommendation; get;";
String queryString2 = "match $x isa person;$y isa $type;{$type label 'product';} or {$type label 'tag';};($x, $y) isa recommendation; get;";
QueryBuilder iqb = snbKB.tx().graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryContainingRelationTypeVar.
@Test
public void testReasoningWithQueryContainingRelationTypeVar() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match (geo-entity: $x) isa $type;$type label 'is-located-in'; get $x;";
String queryString2 = "match (geo-entity: $x, entity-location: $y)isa is-located-in; get $x;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class MatchBenchmark method match.
@Benchmark
public void match() {
Match match = graph.graql().match(var("x").isa(BENCHMARK_ENTITY_TYPE).has(BENCHMARK_ATTRIBUTE_TYPE, "0"));
GetQuery answers = match.get();
Optional<Answer> first = answers.stream().findFirst();
first.get();
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class PhilosophersExampleIT method testAlexanderIsTheOnlyPharaoh.
@Test
public void testAlexanderIsTheOnlyPharaoh() {
GetQuery pharaoh = qb.parse("match has name $x, has title contains 'Pharaoh'; get;");
assertEquals("Alexander", pharaoh.iterator().next().get("x").asAttribute().getValue());
}
Aggregations