use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class AdmissionsKB method buildInstances.
@Override
protected void buildInstances(GraknTx tx) {
Thing Alice = putEntityWithResource(tx, "Alice", applicant, key.getLabel());
Thing Bob = putEntityWithResource(tx, "Bob", applicant, key.getLabel());
Thing Charlie = putEntityWithResource(tx, "Charlie", applicant, key.getLabel());
Thing Denis = putEntityWithResource(tx, "Denis", applicant, key.getLabel());
Thing Eva = putEntityWithResource(tx, "Eva", applicant, key.getLabel());
Thing Frank = putEntityWithResource(tx, "Frank", applicant, key.getLabel());
putResource(Alice, TOEFL, 470L);
putResource(Alice, degreeOrigin, "nonUS");
putResource(Bob, priorGraduateWork, "none");
putResource(Bob, TOEFL, 520L);
putResource(Bob, degreeOrigin, "US");
putResource(Bob, transcript, "unavailable");
putResource(Bob, specialHonours, "none");
putResource(Bob, GRE, 1100L);
putResource(Charlie, priorGraduateWork, "none");
putResource(Charlie, TOEFL, 600L);
putResource(Charlie, degreeOrigin, "US");
putResource(Charlie, transcript, "available");
putResource(Charlie, specialHonours, "none");
putResource(Charlie, GRE, 1100L);
putResource(Charlie, vGRE, 400L);
putResource(Charlie, GPR, 2.99);
putResource(Denis, priorGraduateWork, "none");
putResource(Denis, degreeOrigin, "US");
putResource(Denis, transcript, "available");
putResource(Denis, specialHonours, "none");
putResource(Denis, GRE, 900L);
putResource(Denis, vGRE, 350L);
putResource(Denis, GPR, 2.5);
putResource(Eva, priorGraduateWork, "completed");
putResource(Eva, specialHonours, "valedictorian");
putResource(Eva, GPR, 3.0);
putResource(Frank, TOEFL, 550L);
putResource(Frank, degreeOrigin, "US");
putResource(Frank, transcript, "unavailable");
putResource(Frank, specialHonours, "none");
putResource(Frank, GRE, 100L);
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class LinearTransitivityMatrixKB method buildExtensionalDB.
private void buildExtensionalDB(GraknTx graph, int n, int m) {
Role Qfrom = graph.getRole("Q-from");
Role Qto = graph.getRole("Q-to");
EntityType aEntity = graph.getEntityType("a-entity");
RelationshipType Q = graph.getRelationshipType("Q");
ConceptId[][] aInstancesIds = new ConceptId[n + 1][m + 1];
Thing aInst = putEntityWithResource(graph, "a", graph.getEntityType("entity2"), key);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
aInstancesIds[i][j] = putEntityWithResource(graph, "a" + i + "," + j, aEntity, key).getId();
}
}
Q.addRelationship().addRolePlayer(Qfrom, aInst).addRolePlayer(Qto, graph.getConcept(aInstancesIds[1][1]));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (i < n) {
Q.addRelationship().addRolePlayer(Qfrom, graph.getConcept(aInstancesIds[i][j])).addRolePlayer(Qto, graph.getConcept(aInstancesIds[i + 1][j]));
}
if (j < m) {
Q.addRelationship().addRolePlayer(Qfrom, graph.getConcept(aInstancesIds[i][j])).addRolePlayer(Qto, graph.getConcept(aInstancesIds[i][j + 1]));
}
}
}
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class GrpcServerIT method whenGettingAThing_TheInformationOnTheThingIsCorrect.
@Test
public void whenGettingAThing_TheInformationOnTheThingIsCorrect() {
try (GraknTx remoteTx = remoteSession.open(GraknTxType.READ);
GraknTx localTx = localSession.open(GraknTxType.READ)) {
GetQuery query = remoteTx.graql().match(var("x").has("name", "crime")).get();
Thing remoteConcept = query.stream().findAny().get().get("x").asThing();
Thing localConcept = localTx.getConcept(remoteConcept.getId()).asThing();
assertEquals(localConcept.isInferred(), remoteConcept.isInferred());
assertEquals(localConcept.type().getId(), remoteConcept.type().getId());
assertEqualConcepts(localConcept, remoteConcept, Thing::attributes);
assertEqualConcepts(localConcept, remoteConcept, Thing::keys);
// assertEqualConcepts(localConcept, remoteConcept, Thing::plays); // TODO: re-enable when #19630 is fixed
assertEqualConcepts(localConcept, remoteConcept, Thing::relationships);
}
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class RemoteConceptsTest method whenCallingAllRolePlayers_GetTheExpectedResult.
@Test
public void whenCallingAllRolePlayers_GetTheExpectedResult() {
Role foo = RemoteConcepts.createRole(tx, ConceptId.of("foo"));
Role bar = RemoteConcepts.createRole(tx, ConceptId.of("bar"));
Thing a = RemoteConcepts.createEntity(tx, A);
Thing b = RemoteConcepts.createRelationship(tx, B);
Thing c = RemoteConcepts.createAttribute(tx, C);
Stream<RolePlayer> mockedResponse = Stream.of(RolePlayer.create(foo, a), RolePlayer.create(bar, b), RolePlayer.create(bar, c));
TxResponse response = GET_ROLE_PLAYERS.createTxResponse(server.grpcIterators(), mockedResponse);
server.setResponse(GrpcUtil.runConceptMethodRequest(ID, GET_ROLE_PLAYERS), response);
Map<Role, Set<Thing>> allRolePlayers = relationship.allRolePlayers();
Map<Role, Set<Thing>> expected = ImmutableMap.of(foo, ImmutableSet.of(a), bar, ImmutableSet.of(b, c));
assertEquals(expected, allRolePlayers);
}
use of ai.grakn.concept.Thing in project grakn by graknlabs.
the class RemoteConceptsTest method whenCallingRemoveRolePlayer_ExecuteAConceptMethod.
@Test
public void whenCallingRemoveRolePlayer_ExecuteAConceptMethod() {
Role role = RemoteConcepts.createRole(tx, A);
Thing thing = RemoteConcepts.createEntity(tx, B);
relationship.removeRolePlayer(role, thing);
verifyConceptMethodCalled(ConceptMethods.removeRolePlayer(RolePlayer.create(role, thing)));
}
Aggregations