當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript n3.Parser類代碼示例

本文整理匯總了TypeScript中n3.Parser的典型用法代碼示例。如果您正苦於以下問題:TypeScript Parser類的具體用法?TypeScript Parser怎麽用?TypeScript Parser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Parser類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test_doc_rdf_sync_to_triples_1

function test_doc_rdf_sync_to_triples_1() {
    const parser: N3.N3Parser = new N3.Parser();
    const result = parser.parse(`@prefix c: <http://example.org/cartoons#>.
      c:Tom a c:Cat.
      c:Jerry a c:Mouse;
      c:smarterThan c:Tom.`);
    result.forEach((s) => console.log(s));
}
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:8,代碼來源:n3-tests.ts

示例2: test_doc_rdf_to_triples_1

function test_doc_rdf_to_triples_1() {
    const parser: N3.N3Parser = new N3.Parser();
    parser.parse(`@prefix c: <http://example.org/cartoons#>.
        c:Tom a c:Cat.
        c:Jerry a c:Mouse;
                c:smarterThan c:Tom.`,
        (error: Error, quad: RDF.Quad, prefixes: N3.Prefixes) => {
            if (quad)
                console.log(quad.subject, quad.predicate, quad.object, quad.graph, '.');
            else
                console.log("# That's all, folks!", prefixes);
        });
}
開發者ID:pixelshaded,項目名稱:DefinitelyTyped,代碼行數:13,代碼來源:n3-tests.ts

示例3: test_doc_rdf_stream_to_triples_1

function test_doc_rdf_stream_to_triples_1() {
    const parser: N3.N3Parser = new N3.Parser();
    parser.parse('abc', console.log);

    const streamParser: N3.N3StreamParser = N3.StreamParser();
    const quad: RDF.Quad = streamParser.read();
    const rdfStream = fs.createReadStream('cartoons.ttl');
    const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser);
    streamParser.pipe(new class SlowConsumer extends stream.Writable {
        constructor() {
            super({ objectMode: true });
            this._write = (quad: RDF.Quad, encoding, done) => {
                console.log(quad);
                setTimeout(done, 1000);
            };
        }
    }());
}
開發者ID:pixelshaded,項目名稱:DefinitelyTyped,代碼行數:18,代碼來源:n3-tests.ts

示例4: test_doc_rdf_stream_to_triples_1

function test_doc_rdf_stream_to_triples_1() {
    interface QuadBnode extends N3.BaseQuad {
      subject: N3.BlankNode;
      predicate: N3.BlankNode;
      object: N3.BlankNode;
      graph: N3.BlankNode;
    }
    const parser: N3.N3Parser<QuadBnode> = new N3.Parser<QuadBnode>({factory: N3.DataFactory});
    parser.parse('abc', console.log);

    const streamParser: N3.N3StreamParser = N3.StreamParser();
    const quad: RDF.Quad = streamParser.read();
    const rdfStream = fs.createReadStream('cartoons.ttl');
    const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser);
    streamParser.pipe(new class SlowConsumer extends stream.Writable {
        constructor() {
            super({ objectMode: true });
            this._write = (quad: RDF.Quad, encoding, done) => {
                console.log(quad);
                setTimeout(done, 1000);
            };
        }
    }());
}
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:24,代碼來源:n3-tests.ts


注:本文中的n3.Parser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。