当前位置: 首页>>代码示例>>Java>>正文


Java StreamRDFLib类代码示例

本文整理汇总了Java中org.apache.jena.riot.system.StreamRDFLib的典型用法代码示例。如果您正苦于以下问题:Java StreamRDFLib类的具体用法?Java StreamRDFLib怎么用?Java StreamRDFLib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StreamRDFLib类属于org.apache.jena.riot.system包,在下文中一共展示了StreamRDFLib类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: expand

import org.apache.jena.riot.system.StreamRDFLib; //导入依赖的package包/类
public static void expand() throws IOException {
    boolean combined = false ;
    String DIR = "testing/Inf" ;
    String DATA_FILE = "data.ttl" ;
    String VOCAB_FILE = "vocab.ttl" ;
    String RULES_FILE = DIR+"/rdfs-min.rules" ;

    Model vocab = RDFDataMgr.loadModel(VOCAB_FILE) ;
    Model data = RDFDataMgr.loadModel(DATA_FILE) ;
    
    String rules = FileUtils.readWholeFileAsUTF8(RULES_FILE) ;
    rules = rules.replaceAll("#[^\\n]*", "") ;

    InferenceSetupRDFS setup = new InferenceSetupRDFS(vocab, combined) ;
    
    Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
    InfModel m = ModelFactory.createInfModel(reasoner, vocab, data);
    
    // Expansion Graph
    Graph graphExpanded = Factory.createDefaultGraph() ;
    StreamRDF stream = StreamRDFLib.graph(graphExpanded) ;
    // Apply inferences.
    stream = new InferenceProcessorStreamRDF(stream, setup) ;
    sendToStream(data.getGraph(), stream) ;
    RDFDataMgr.write(System.out, graphExpanded, Lang.TTL) ;
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:27,代码来源:DevRDFS.java

示例2: datasource_init_01

import org.apache.jena.riot.system.StreamRDFLib; //导入依赖的package包/类
@Test
public void datasource_init_01() {
    DeltaLink dLink = getLinkRegistered();
    Id dsRef = dLink.newDataSource("datasource_15", "http://example/uri");
    assertEquals(1, dLink.listDatasets().size());
    DataSourceDescription dsd = dLink.getDataSourceDescriptionByURI("http://example/uri-not-present");
    String url = dLink.initialState(dsRef);
    assertNotNull(url);
    RDFDataMgr.parse(StreamRDFLib.sinkNull(), url);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:11,代码来源:AbstractTestDeltaLink.java

示例3: setupHere

import org.apache.jena.riot.system.StreamRDFLib; //导入依赖的package包/类
@BeforeClass public static void setupHere() {
    Graph dataTest = GraphFactory.createDefaultGraph() ;
    testGraphExpanded = GraphFactory.createDefaultGraph() ;
    GraphUtil.addInto(dataTest, data) ;
    GraphUtil.addInto(dataTest, vocab) ;
    InferenceSetupRDFS setup = new InferenceSetupRDFS(vocab, true) ;
    StreamRDF stream = StreamRDFLib.graph(testGraphExpanded) ;
    stream = new InferenceProcessorStreamRDF(stream, setup) ;
    StreamOps.graphToStream(dataTest, stream) ;
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:11,代码来源:TestExpandCombinedRDFS.java

示例4: setupHere

import org.apache.jena.riot.system.StreamRDFLib; //导入依赖的package包/类
@BeforeClass public static void setupHere() {
    testGraphExpanded = GraphFactory.createDefaultGraph() ;
    InferenceSetupRDFS setup = new InferenceSetupRDFS(vocab, false) ;
    StreamRDF stream = StreamRDFLib.graph(testGraphExpanded) ;
    stream = new InferenceProcessorStreamRDF(stream, setup) ;
    StreamOps.graphToStream(data, stream) ;
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:8,代码来源:TestExpandSplitRDFS.java

示例5: parseSynchronusly

import org.apache.jena.riot.system.StreamRDFLib; //导入依赖的package包/类
@Override
protected void parseSynchronusly() throws IOException {
    StreamRDF dest;
    final JenaRDF jenaRDF = getJenaFactory();
    if (getTargetGraph().isPresent() && getTargetGraph().get() instanceof JenaGraph) {
        final Graph jenaGraph = ((JenaGraph) getTargetGraph().get()).asJenaGraph();
        dest = StreamRDFLib.graph(jenaGraph);
    } else {
        if (generalizedConsumerQuad != null) {
            dest = jenaRDF.streamJenaToGeneralizedQuad(generalizedConsumerQuad);
        } else if (generalizedConsumerTriple != null) {
            dest = jenaRDF.streamJenaToGeneralizedTriple(generalizedConsumerTriple);
        } else {
            dest = JenaRDF.streamJenaToQuad(getRdfTermFactory().get(), getTarget());
        }
    }

    final Lang lang = getContentTypeSyntax().flatMap(jenaRDF::asJenaLang).orElse(null);
    final String baseStr = getBase().map(IRI::getIRIString).orElse(null);

    if (getSourceIri().isPresent()) {
    	    RDFParser.source(getSourceIri().get().toString()).base(baseStr).lang(lang).parse(dest);
    } else if (getSourceFile().isPresent()) {
        try (InputStream s = Files.newInputStream(getSourceFile().get())) {
        	    RDFParser.source(s).base(baseStr).lang(lang).parse(dest);
        }
    } else {
        RDFParser.source(getSourceInputStream().get()).base(baseStr).lang(lang).parse(dest);
    }
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:31,代码来源:JenaRDFParser.java

示例6: main

import org.apache.jena.riot.system.StreamRDFLib; //导入依赖的package包/类
public static void main(String...argv) {
    Logger LOG = LoggerFactory.getLogger("Load");
    
    if ( argv.length == 0 ) {
        System.err.println("Usage: load FILE...");
        System.exit(1);
    }

    String[] args = argv; //new String[] {"/home/afs/Datasets/BSBM/bsbm-5m.nt.gz"};
    
    String DIR = "ZoneX";
    String URL = "http://localhost:1066/";
    String DS  = "DS";
    
    FileOps.ensureDir(DIR); 
    FileOps.clearDirectory(DIR);
    Zone zone = Zone.connect(Location.create(DIR));
    DeltaLink dLink = DeltaLinkHTTP.connect(URL);
    Id clientId = Id.create();
    dLink.register(clientId);
    
    DeltaClient dClient = DeltaClient.create(zone, dLink);
    Id dsRef = dClient.newDataSource(DS, "http://example/"+DS);
    dClient.register(dsRef, LocalStorageType.TDB, TxnSyncPolicy.TXN_RW);
    
    long count = -99;
    Timer timer = new Timer();
    timer.startTimer();
    try ( DeltaConnection dConn = dClient.get(dsRef) ) {
        DatasetGraph dsg = dConn.getDatasetGraph();
        StreamRDF dest = StreamRDFLib.dataset(dsg);
        StreamRDFCounting cdest = StreamRDFLib.count(dest);
        Txn.executeWrite(dsg, ()->{
            for ( String fn : args ) {
                System.out.printf("File: %s\n", fn);
                RDFDataMgr.parse(cdest, fn);
            }
        });
        count = cdest.count();   
    }
    long x = timer.endTimer();
    double seconds = x/1000.0;
    FmtLog.info(LOG, "Time  = %.2fs\n", seconds);
    FmtLog.info(LOG, "Count = %,d\n", count);
    FmtLog.info(LOG, "Rate  = %,.2f TPS\n", count/seconds);
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:47,代码来源:load.java

示例7: setModel

import org.apache.jena.riot.system.StreamRDFLib; //导入依赖的package包/类
/**
 * Set a model into which the conversion results will be stored.
 * @see #setOutputStream(StreamRDF)
 */
public void setModel(Model model) {
    result = model;
    outputStream = StreamRDFLib.graph( result.getGraph() );
}
 
开发者ID:epimorphics,项目名称:dclib,代码行数:9,代码来源:ConverterProcess.java


注:本文中的org.apache.jena.riot.system.StreamRDFLib类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。