use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GenealogyTest method matchAllRelationsWithDocumentPlayingARole.
/*
test for first rule file:
match $x isa person has first-name $name;
match (child: $x, parent: $y) isa parentship;
match (spouse: $x, spouse: $y) isa marriage;
*/
@Test
public void matchAllRelationsWithDocumentPlayingARole() {
String queryString = "match $x isa document; ($x, $y); get;";
GetQuery query = iqb.parse(queryString);
List<Answer> answers = query.execute();
assertTrue(answers.isEmpty());
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class GenealogyTest method testParentship.
@Test
public void testParentship() {
String queryString = "match (child: $c, parent: $p) isa parentship; get;";
GetQuery query = iqb.parse(queryString);
List<Answer> answers = query.execute();
assertEquals(answers.size(), 76);
assertTrue(!hasDuplicates(answers));
answers.forEach(answer -> assertEquals(answer.size(), 2));
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ExplanationTest method testExplainingConjunctions.
@Test
public void testExplainingConjunctions() {
GraknTx expGraph = explanationKB.tx();
QueryBuilder eiqb = expGraph.graql().infer(true);
String queryString = "match " + "(role1: $x, role2: $w) isa inferredRelation;" + "$x has name $xName;" + "$w has name $wName; get;";
GetQuery query = eiqb.parse(queryString);
List<Answer> answers = query.execute();
testExplanation(answers);
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ExplanationTest method testExplainingNonRuleResolvableQuery.
@Test
public void testExplainingNonRuleResolvableQuery() {
String queryString = "match $x isa city, has name $n; get;";
GetQuery query = iqb.parse(queryString);
List<Answer> answers = query.execute();
answers.forEach(ans -> assertEquals(ans.getExplanation().isEmpty(), true));
}
use of ai.grakn.graql.GetQuery in project grakn by graknlabs.
the class ExplanationTest method testExplainingQueryContainingContradiction2.
@Test
public void testExplainingQueryContainingContradiction2() {
GraknTx expGraph = explanationKB.tx();
QueryBuilder eiqb = expGraph.graql().infer(true);
Concept a1 = getConcept(expGraph, "name", "a1");
Concept a2 = getConcept(expGraph, "name", "a2");
String queryString = "match " + "(role1: $x, role2: $y) isa relation1;" + "$x id '" + a1.getId() + "';" + "$y id '" + a2.getId() + "'; get;";
GetQuery query = eiqb.parse(queryString);
List<Answer> answers = query.execute();
assertEquals(answers.size(), 0);
}
Aggregations