This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Grakn = require("grakn"); | |
const fs = require("fs"); | |
const papa = require("papaparse"); | |
const inputs = [ | |
{ dataPath: "./data/companies", template: companyTemplate }, | |
{ dataPath: "./data/people", template: personTemplate }, | |
{ dataPath: "./data/contracts", template: contractTemplate }, | |
{ dataPath: "./data/calls", template: callTemplate } | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Grakn = require("grakn"); | |
const grakn = new Grakn("localhost:48555"); | |
const session = grakn.session("phone_calls"); | |
ExecuteMatchQuery(); | |
async function ExecuteMatchQuery() { | |
const tx = await session.transaction(Grakn.txType.READ); | |
let query = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Grakn = require("grakn"); | |
const grakn = new Grakn("localhost:48555"); | |
const session = grakn.session("phone_calls"); | |
ExecuteMatchQuery(); | |
async function ExecuteMatchQuery() { | |
const tx = await session.transaction(Grakn.txType.READ); | |
let query = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Grakn = require("grakn"); | |
const grakn = new Grakn("localhost:48555"); | |
const session = grakn.session("phone_calls"); | |
ExecuteMatchQuery(); | |
async function ExecuteMatchQuery() { | |
const tx = await session.transaction(Grakn.txType.READ); | |
let query = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Grakn = require("grakn"); | |
const grakn = new Grakn("localhost:48555"); | |
const session = grakn.session("phone_calls"); | |
ExecuteMatchQuery(); | |
async function ExecuteMatchQuery() { | |
const tx = await session.transaction(Grakn.txType.READ); | |
let query = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define | |
contract sub relationship, | |
relates provider, | |
relates customer; | |
call sub relationship, | |
relates caller, | |
relates callee, | |
has started-at, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Grakn = require("grakn"); | |
const inputs = [ | |
{ | |
dataPath: "./data/companies", | |
template: companyTemplate | |
}, | |
{ | |
dataPath: "./data/people", | |
template: personTemplate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function buildPhoneCallGraph(inputs) { | |
const grakn = new Grakn("localhost:48555"); | |
const session = grakn.session("phone_calls"); | |
for (input of inputs) { | |
await loadDataIntoGrakn(parsingInput, session); | |
} | |
session.close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function loadDataIntoGrakn(input, session) { | |
const items = await parseDataToObjects(input); | |
for (item of items) { | |
const tx = await session.transaction(Grakn.txType.WRITE); | |
const graqlInsertQuery = input.template(item); | |
await tx.query(graqlInsertQuery); | |
await tx.commit(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function companyTemplate(company) { | |
return `insert $company isa company has name "${company.name}";`; | |
} |
OlderNewer