Skip to content

Commit

Permalink
Use riot to merge turtles
Browse files Browse the repository at this point in the history
  • Loading branch information
bherr2 committed Nov 22, 2024
1 parent 5f718fa commit a0001ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/finalizing/merge-catalogs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { resolve } from 'path';
import sh from 'shelljs';
import { mergeTurtles } from '../utils/blazegraph.js';
import { reifyTurtle } from '../utils/reify.js';
import { mergeTurtles, reifyTurtle } from '../utils/reify.js';

export function mergeCatalogs(context) {
const graphs = listMetadataGraphs(context);
Expand Down
7 changes: 6 additions & 1 deletion src/utils/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ export function reifyTurtle(inputPath, graphName, jsonldIsJson = false) {
export function convert(inputPath, outputPath, outputFormat, graphName) {
let command = `riot --merge --nocheck --output=${outputFormat} "${inputPath}"`;
if (isJsonLd(inputPath)) {
command = `cat "${inputPath}" | jsonld toRdf -q | riot --merge --nocheck --output=turtle`
command = `cat "${inputPath}" | jsonld toRdf -q | riot --merge --nocheck --output=turtle`;
}
if (graphName && outputFormat === FORMATS.nq) {
command += ` | perl -pe 's|\ \.\n|\ <${graphName}> .\n|g'`;
}
throwOnError(`${command} > ${outputPath}`, `Failed to convert to '${outputFormat}' format.`);
}

export function mergeTurtles(outputPath, _prefixesPath, ontologyPaths) {
const inputFiles = ontologyPaths.join(' ');
throwOnError(`riot --merge --nocheck --output=turtle ${inputFiles} > ${outputPath}`, `${inputFiles} failed to load`);
}

0 comments on commit a0001ab

Please sign in to comment.