本文整理匯總了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);
};
}
});
}