use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryContainingLimit.
@Test
public void testReasoningWithQueryContainingLimit() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String limitQueryString = "match (geo-entity: $x, entity-location: $y)isa is-located-in;limit 5; get;";
String queryString = "match (geo-entity: $x, entity-location: $y)isa is-located-in; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery limitQuery = iqb.parse(limitQueryString);
GetQuery query = iqb.parse(queryString);
List<Answer> limitedAnswers = limitQuery.execute();
List<Answer> answers = query.execute();
assertEquals(limitedAnswers.size(), 5);
assertTrue(answers.size() > limitedAnswers.size());
assertTrue(answers.containsAll(limitedAnswers));
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testParsingQueryContainingDataType.
@Test
public void testParsingQueryContainingDataType() {
String queryString = " match $x sub " + Schema.MetaSchema.ATTRIBUTE.getLabel().getValue() + ", datatype string; get;";
GetQuery query = snbKB.tx().graql().infer(true).parse(queryString);
GetQuery query2 = snbKB.tx().graql().infer(false).parse(queryString);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testParsingQueryContainingTypeRegex.
@Test
public void testParsingQueryContainingTypeRegex() {
String queryString = " match $x sub " + Schema.MetaSchema.ATTRIBUTE.getLabel().getValue() + ", regex /name/; get;";
GetQuery query = snbKB.tx().graql().infer(true).parse(queryString);
GetQuery query2 = snbKB.tx().graql().infer(false).parse(queryString);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryContainingResourceComparison.
@Test
public void testReasoningWithQueryContainingResourceComparison() {
// recommendations of products for people older than Denis - Frank, Karl and Gary
String queryString = "match " + "$b has name 'Denis', has age $x;" + "$p has name $name, has age $y; $y val > $x;" + "$pr isa product;($p, $pr) isa recommendation;" + "get $p, $y, $pr, $name;";
String explicitQuery = "match $p isa person, has age $y, has name $name;$pr isa product, has name $yName;" + "{$name val 'Frank';$yName val 'Nocturnes';} or" + "{$name val 'Karl Fischer';{$yName val 'Faust';} or {$yName val 'Nocturnes';};} or " + "{$name val 'Gary';$yName val 'The Wall';};get $p, $pr, $y, $name;";
GetQuery query = snbKB.tx().graql().infer(true).parse(queryString);
GetQuery query2 = snbKB.tx().graql().infer(false).parse(explicitQuery);
assertQueriesEqual(query, query2);
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ReasonerTest method testReasoningWithQueryWithNoRelationTypeWithRoles2.
@Test
public void testReasoningWithQueryWithNoRelationTypeWithRoles2() {
GraknTx graph = nonMaterialisedGeoKB.tx();
String queryString = "match $x isa city;$y isa country;(geo-entity: $x, $y); get;";
String queryString2 = "match $x isa city;$y isa country;" + "(geo-entity: $x, entity-location: $y) isa is-located-in; get;";
QueryBuilder iqb = graph.graql().infer(true);
GetQuery query = iqb.parse(queryString);
GetQuery query2 = iqb.parse(queryString2);
assertQueriesEqual(query, query2);
}
Aggregations