本文整理汇总了TypeScript中n3.Parser函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Parser函数的具体用法?TypeScript Parser怎么用?TypeScript Parser使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Parser函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test_doc_rdf_to_triples_2
function test_doc_rdf_to_triples_2() {
var parser1 = N3.Parser({ format: 'N-Triples' });
var parser2 = N3.Parser({ format: 'application/trig' });
// Notation3 (N3) is supported only through the format argument:
var parser3 = N3.Parser({ format: 'N3' });
var parser4 = N3.Parser({ format: 'Notation3' });
var parser5 = N3.Parser({ format: 'text/n3' });
}
示例2: test_doc_rdf_to_triples_2
function test_doc_rdf_to_triples_2() {
const parser1: N3.N3Parser = new N3.Parser({ format: 'N-Triples' });
const parser2: N3.N3Parser = new N3.Parser({ format: 'application/trig' });
// Notation3 (N3) is supported only through the format argument:
const parser3: N3.N3Parser = N3.Parser({ format: 'N3' });
const parser4: N3.N3Parser = N3.Parser({ format: 'Notation3' });
const parser5: N3.N3Parser = N3.Parser({ format: 'text/n3' });
}
示例3: test_doc_utility
function test_doc_utility() {
var N3Util = N3.Util;
N3Util.isIRI('http://example.org/cartoons#Mickey'); // true
N3Util.isLiteral('"Mickey Mouse"'); // true
N3Util.getLiteralValue('"Mickey Mouse"'); // 'Mickey Mouse'
N3Util.isLiteral('"Mickey Mouse"@en'); // true
N3Util.getLiteralLanguage('"Mickey Mouse"@en'); // 'en'
N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true
N3Util.getLiteralType('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // 'http://www.w3.org/2001/XMLSchema#integer'
N3Util.isLiteral('"http://example.org/"'); // true
N3Util.getLiteralValue('"http://example.org/"'); // 'http://example.org/'
N3Util.isLiteral('"This word is "quoted"!"'); // true
N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true
N3.Parser().parse('<a> <b> "This word is \\"quoted\\"!".', console.log);
// { subject: 'a', predicate: 'b', object: '"This word is "quoted"!"' }
N3Util.createLiteral('My text', 'en-gb');
N3Util.createLiteral('123', 'http://www.w3.org/2001/XMLSchema#integer');
N3Util.createLiteral(123);
N3Util.createLiteral(false);
N3Util.isBlank('_:b1'); // true
N3Util.isIRI('_:b1'); // false
N3Util.isLiteral('_:b1'); // false
var prefixes: N3.Prefixes = { rdfs: 'http://www.w3.org/2000/01/rdf-schema#' };
N3Util.isPrefixedName('rdfs:label'); // true;
N3Util.expandPrefixedName('rdfs:label', prefixes); // http://www.w3.org/2000/01/rdf-schema#label
}
示例4: test_doc_rdf_to_triples_1
function test_doc_rdf_to_triples_1() {
var parser = N3.Parser();
parser.parse('@prefix c: <http://example.org/cartoons#>.\n' +
'c:Tom a c:Cat.\n' +
'c:Jerry a c:Mouse;\n' +
' c:smarterThan c:Tom.',
function (error: Error, triple: N3.Triple, prefixes: N3.Prefixes) {
if (triple)
console.log(triple.subject, triple.predicate, triple.object, '.');
else
console.log("# That's all, folks!", prefixes)
});
}
示例5: test_doc_rdf_stream_to_triples_1
function test_doc_rdf_stream_to_triples_1() {
var parser = N3.Parser();
var rdfStream = fs.createReadStream('cartoons.ttl');
parser.parse(rdfStream, console.log);
var streamParser = N3.StreamParser();
var rdfStream = fs.createReadStream('cartoons.ttl');
rdfStream.pipe(streamParser);
streamParser.pipe(new class SlowConsumer extends stream.Writable {
constructor() {
super({ objectMode: true });
this._write = function (triple, encoding, done) {
console.log(triple);
setTimeout(done, 1000);
};
}
});
}