Thomas de Groot (thomas.de.groot@triply.cc)
RATT | RML | COW | |
---|---|---|---|
Language: | Typescript | Java/ttl | Python/JSON-LD |
works: | Out of the box | Needs interpreter | Needs interpreter |
linked data | No | Yes | Yes |
Standard: | No | Yes | Yes |
Input format: | Everything | csv, json, xml | csv |
expandable | Yes | Limited | Limited |
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix graph: <https://triplydb.com/academy/stolpersteine/graph/>
prefix person: <https://triplydb.com/academy/stolpersteine/id/person/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix time: <http://www.w3.org/2006/time#>
prefix def: <https://triplydb.com/academy/stolpersteine/def/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix void: <http://rdfs.org/ns/void#>
// Ratt application
const configObject = {
defaultGraph: NamedNode,
};
const app = new Ratt(configObject);
// Middleware context, record and store
class Context {
record: Record; // [key: string]: unknown;
store: Store; // N3Store
}
// read from array:
app.use(fromArray(input: string[][], opts: {columns: boolean});
// read from csv:
app.use(fromCsv(files: string | string[], opts:{compressed: boolean, columns: boolean}))
// read from shapeFile:
app.use(fromShapeFile(files: string | string[]))
// read from xml(Not generic yet):
app.use(readXml(files: string | string[], opts: Config)))
app.use(set(key: string; value: (ctx) => return "" ))
app.use(copy(fromKey: string; toKey: string; change?: (val, ctx) => return `${val}` ))
app.use(change(key: string; change: (val, ctx) => return val ? 0 : 1 ))
app.use(remove(key: string; when: (val, ctx) => return ctx.record.Reason ))
app.use(addQuad(toNamedNode("COLUMN-person"), rdf("type"), def("Person")))
app.use([addQuad((ctx) => {return person(ctx.record.COLUMN-person);}, def("mother"), toNamedNode("COLUMN-mother")),
addQuad(toNamedNode("COLUMN-person"), rdfs("label"), toLiteral("T Riply", { datatype: xsd("string") }),
addQuad(toNamedNode("COLUMN-person"), foaf("name"), toLiteral("Tim", { language: "nl" })),
addQuad(toNamedNode("COLUMN-person", {prefix: person}), sdo("countryOfOrigin"), DataFactory.literal("Netherlands")),
addQuad(toNamedNode("COLUMN-person"), toNamedNode("adres"),toBnode([
[rdf("type"), sdo("Address")],
[foaf("name"), toLiteral("gemeenteNaam")]]))]);
app.useWhen((ctx) => {return !!ctx.record.COLUMN-kind;},
addQuad(toNamedNode("COLUMN-person"), sdo("child"), person("COLUMN-kind")));
// Write to file middelware
app.use(writeToFile(path.resolve(outputDir, "dummy.nq"), {compress: true}));
// execute
await app.run();
//Upload to TriplyDB
const account = await getAccount();
const ds = await putDs(account, { name: `dummy` });
await ds.importFromFiles(path.resolve(outputDir, "dummy.nq"));
Install Node and follow the steps for your OS.
Install Yarn and follow the steps for your OS.
git clone ssh://git@git.triply.cc:10072/triply/boilerplates.git
./bootstrapBoilerplate --name myNewEtl --boilerplate etl ~/triply/myNewEtl
yarn
yarn run build
yarn run start