Page MenuHomec4science

rdf-editor-component.component.ts
No OneTemporary

File Metadata

Created
Fri, Apr 19, 21:40

rdf-editor-component.component.ts

import { Component, OnInit } from '@angular/core';
import * as N3 from "node_modules/n3/src";
@Component({
selector: 'app-rdf-editor-component',
templateUrl: './rdf-editor-component.component.html',
styleUrls: ['./rdf-editor-component.component.scss']
})
export class RdfEditorComponentComponent implements OnInit {
constructor() {
}
ngOnInit() {
const {DataFactory} = N3;
const {namedNode, literal, defaultGraph, quad} = DataFactory;
const myQuad = quad(
namedNode('https://ruben.verborgh.org/profile/#me'),
namedNode('http://xmlns.com/foaf/0.1/givenName'),
literal('Ruben', 'en'),
defaultGraph(),
);
console.log(myQuad.termType); // Quad
console.log(myQuad.value); // ''
console.log(myQuad.subject.value); // https://ruben.verborgh.org/profile/#me
console.log(myQuad.object.value); // Ruben
console.log(myQuad.object.datatype.value); // http://www.w3.org/1999/02/22-rdf-syntax-ns#langString
console.log(myQuad.object.language); // en
this.writeSth();
}
interLinkTextUnits(textA: string, textB: string): string {
let ttlString: string;
return ttlString;
}
writeSth() {
const {DataFactory} = N3;
const {namedNode, literal, defaultGraph, quad} = DataFactory;
const writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } });
writer.addQuad(
namedNode('http://example.org/cartoons#Tom'),
namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
namedNode('http://example.org/cartoons#Cat')
);
writer.addQuad(quad(
namedNode('http://example.org/cartoons#Tom'),
namedNode('http://example.org/cartoons#name'),
literal('Tom')
));
writer.end((error, result) => console.log('typeof ', typeof result, ' result ', result));
}
}

Event Timeline