@pepoospina It seems I have some issues to address on running ts, which I will address. I played a bit on an online playground, and I think I finished the TriG generation, but I can't test the whole thing, of course. I am attaching it here so that I won't be committing to the changes. I can commit to a new branch if it seems better for you.
Here is the script with adding triplets orchid and correct prefixes.
`import { Nanopub } from '@nanopub/sign';
import { AppPostCreate, AppUserRead } from '../@shared/types';
//reformat the triplets from AppPostCreate to be added as predicate and object
//to the subject :assertion
function processTriplets(triplets: string[]): string[] {
return triplets.map(triplet => {
let firstGreaterIndex = triplet.indexOf('>');
return triplet.substring(firstGreaterIndex + 1).trim() + ';';
});
}
export const constructNanopub = async (
postCreateData: AppPostCreate,
user: AppUserRead
): Promise => {
// Process the triplets
const processedTriplets = processTriplets(postCreateData.semantics?.triplets)
// Convert the array of triplets to a single string
const tripletsStr = processedTriplets.join('\n ');
@pepoospina It seems I have some issues to address on running ts, which I will address. I played a bit on an online playground, and I think I finished the TriG generation, but I can't test the whole thing, of course. I am attaching it here so that I won't be committing to the changes. I can commit to a new branch if it seems better for you. Here is the script with adding triplets orchid and correct prefixes. `import { Nanopub } from '@nanopub/sign';
import { AppPostCreate, AppUserRead } from '../@shared/types';
//reformat the triplets from AppPostCreate to be added as predicate and object
//to the subject :assertion function processTriplets(triplets: string[]): string[] { return triplets.map(triplet => { let firstGreaterIndex = triplet.indexOf('>'); return triplet.substring(firstGreaterIndex + 1).trim() + ';'; }); }
export const constructNanopub = async ( postCreateData: AppPostCreate, user: AppUserRead ): Promise => {
// Process the triplets
const processedTriplets = processTriplets(postCreateData.semantics?.triplets)
// Convert the array of triplets to a single string
const tripletsStr = processedTriplets.join('\n ');
const rdfStr = ` @prefix this: https://w3id.org/np/RAuohvU0INLVpmB8kpddnyx5zHOb-NbjoFgYM-AgZU9eY . @prefix sub: https://w3id.org/np/RAuohvU0INLVpmB8kpddnyx5zHOb-NbjoFgYM-AgZU9eY# . @prefix np: http://www.nanopub.org/nschema# . @prefix dct: http://purl.org/dc/terms/ . @prefix nt: https://w3id.org/np/o/ntemplate/ . @prefix npx: http://purl.org/nanopub/x/ . @prefix xsd: http://www.w3.org/2001/XMLSchema# . @prefix rdfs: http://www.w3.org/2000/01/rdf-schema# . @prefix orcid: https://orcid.org/ . @prefix ns1: http://purl.org/np/ . @prefix prov: http://www.w3.org/ns/prov# . @prefix foaf: http://xmlns.com/foaf/0.1/ .
`;
const np = new Nanopub(rdfStr); return np; };`