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


Java PipedRDFStream类代码示例

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


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

示例1: parse

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
public static PipedRDFIterator<Triple> parse(String dump){
    PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
    final String d=dump;
    System.out.println(d);
    final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iter);
    // PipedRDFStream and PipedRDFIterator need to be on different threads
    ExecutorService executor = Executors.newSingleThreadExecutor();
    // Create a runnable for our parser thread
    Runnable parser = new Runnable() {
        @Override
        public void run() {
            // Call the parsing process.
            RDFDataMgr.parse(inputStream, d);
        }
    };

    // Start the parser on another thread
    executor.submit(parser);
    return iter;
}
 
开发者ID:WDAqua,项目名称:PageRankRDF,代码行数:21,代码来源:Parser.java

示例2: test00GetVoidInformation

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * 0.nt
 */
@Test
public final void test00GetVoidInformation() {
    // set input file
    String inFile = "src/test/data/0.nt";
    // run extraction
    try {
        // setup
        InputStream inStream = new FileInputStream( inFile );
        PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
        PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
        // run
        RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
        VoidParsingExtractor extractor = new VoidParsingExtractor();
        extractor.extract( iter );
        // print
        System.out.println( "0.nt\n  " + extractor.getVoidInformation().toString() );
        // test
        assertEquals( 0, extractor.getVoidInformation().size() );
    }
    catch( Exception e ) {
        fail( e.toString() );
    }
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例3: test051GetVoidInformation

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * 5.nt
 */
@Test
public final void test051GetVoidInformation() {
    // set input file
    String inFile = "src/test/data/5.nt";
    // run extraction
    try {
        // setup
        InputStream inStream = new FileInputStream( inFile );
        PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
        PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
        // run
        RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
        VoidParsingExtractor extractor = new VoidParsingExtractor();
        extractor.extract( iter );
        // print
        System.out.println( "5.nt:\n  " + extractor.getVoidInformation().toString() );
        // test
        assertEquals( 0, extractor.getVoidInformation().size() );
    }
    catch( Exception e ) {
        fail( e.toString() );
    }
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例4: test052GetVoidInformation

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * Test method for VoidParsingExtractor#getVoidInformation()
 * expected_5.nt
 */
@Test
public final void test052GetVoidInformation() {
    // set input file
    String inFile = "src/test/data/expected_5.nt";
    // run extraction
    try {
        // setup
        InputStream inStream = new FileInputStream( inFile );
        PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
        PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
        // run
        RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
        VoidParsingExtractor extractor = new VoidParsingExtractor();
        extractor.extract( iter );
        // print
        System.out.println( "expected_5.nt:\n  " + extractor.getVoidInformation().toString() );
        // test
        assertEquals( 11, extractor.getVoidInformation().size() );
    }
    catch( Exception e ) {
        fail( e.toString() );
    }		
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:28,代码来源:VoidParsingExtractorTest.java

示例5: open

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
@Override
public void open(Map conf, TopologyContext context,	SpoutOutputCollector collector) {
    this.collector = collector;
    
    //Sink<Triple> output = new SinkTripleOutput(System.out, null, SyntaxLabels.createNodeToLabel());
    iterator = new PipedRDFIterator<Triple>();
       final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iterator);

    // PipedRDFStream and PipedRDFIterator need to be on different threads
       ExecutorService executor = Executors.newSingleThreadExecutor();

       // Create a runnable for our parser thread
       Runnable parser = new Runnable() {

           @Override
           public void run() {
               // Call the parsing process.
               RDFDataMgr.parse(inputStream, filePath, Lang.TURTLE);
           }
       };

       // Start the parser on another thread
       executor.submit(parser);
}
 
开发者ID:allaves,项目名称:storm-query-operators,代码行数:25,代码来源:RDFStreamSpout.java

示例6: streamParser

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public PipedRDFIterator<?> streamParser(final String fileName){
    PipedRDFIterator<?> iterator = new PipedRDFIterator<Triple>();
    final PipedRDFStream<?> rdfStream = new PipedTriplesStream((PipedRDFIterator<Triple>) iterator);
    
    ExecutorService executor = Executors.newSingleThreadExecutor();

    Runnable parser = new Runnable(){
        @Override
        public void run() {
            try{
                RDFDataMgr.parse(rdfStream, fileName);
            } catch (Exception e){
                rdfStream.finish();
            }
        }			
    };
    executor.submit(parser);

    
    return iterator;
}
 
开发者ID:diachron,项目名称:quality,代码行数:23,代码来源:TestLoader.java

示例7: runExtraction

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
public boolean runExtraction(String rdfData, String baseUri, Lang language, Extractor... extractors) {
    PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
    PipedRDFStream<Triple> rdfStream = new PipedTriplesStream(iter);
    BlockingStreamRDFDecorator streamDecorator = new BlockingStreamRDFDecorator(rdfStream);
    return runExtraction(iter, streamDecorator,
            new String2RDFStreamingTask(streamDecorator, new StringReader(rdfData), baseUri, language), extractors);
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:8,代码来源:RDF2ExtractionStreamer.java

示例8: runExtraction

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * (Variation 1)
 * 
 * @param is Input stream
 * @param baseUri URI of data set
 * @param language Language of data set
 * @param extractors Extractor
 * @return TRUE or FALSE
 */
public boolean runExtraction(InputStream is, String baseUri, Lang language, Extractor... extractors) {
    // create iterator
    PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
    
    // create stream
    PipedRDFStream<Triple> rdfStream = new PipedTriplesStream(iter);
    
    // create decorator
    BlockingStreamRDFDecorator streamDecorator = new BlockingStreamRDFDecorator(rdfStream);
    
    // call function again
    return runExtraction(iter, streamDecorator,
            new InputStream2RDFStreamingTask(streamDecorator, is, baseUri, language), extractors);        
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:24,代码来源:RDF2ExtractionStreamer.java

示例9: test00GetCountedClasses

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * Test method for VoidExtractor#getCountedClasses().
 * 0.nt
 */
@Test
public final void test00GetCountedClasses() {
    // set input file
    String inFile = "src/test/data/0.nt";
    // set expected result
    ObjectIntOpenHashMap<String> expected = new ObjectIntOpenHashMap<String>();
    expected.putOrAdd( "http://example.org/Class1", 1, 1 );
    expected.putOrAdd( "http://example.org/Class2", 0, 0 );
    expected.putOrAdd( "http://www.w3.org/2000/01/rdf-schema#Class", 1, 1 );
    // run extraction
    try {
        // setup
        InputStream inStream = new FileInputStream( inFile );
        PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
        PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
        // run
        RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
        VoidExtractor extractor = new VoidExtractor();
        extractor.extract( iter );
        // print
        System.out.println( "0.nt:\n  CLASSES: " + extractor.getCountedClasses().toString() );
        // test
        assertEquals( expected, extractor.getCountedClasses() );
    }
    catch( Exception e ) {
        fail( e.toString() );
    }
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:33,代码来源:VoidExtractorTest.java

示例10: test05GetCountedClasses

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * Test method for VoidExtractor#getCountedClasses().
 * 5.nt
 */
@Test
public final void test05GetCountedClasses() {
    // set input file
    String inFile = "src/test/data/5.nt";
    // set expected result
    ObjectIntOpenHashMap<String> expected = new ObjectIntOpenHashMap<String>();
    expected.putOrAdd( "http://example.org/class2", 0, 0 );
    expected.putOrAdd( "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property", 2, 2 );
    expected.putOrAdd( "http://example.org/class1", 0, 0 );
    expected.putOrAdd( "http://www.w3.org/2000/01/rdf-schema#Class", 2, 2 );
    // run extraction
    try {
        // setup
        InputStream inStream = new FileInputStream( inFile );
        PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
        PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
        // run
        RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
        VoidExtractor extractor = new VoidExtractor();
        extractor.extract( iter );
        // print
        System.out.println( "5.nt:\n  CLASSES: " + extractor.getCountedClasses().toString() );
        // test
        assertEquals( expected, extractor.getCountedClasses() );
    }
    catch( Exception e ) {
        fail( e.toString() );
    }
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:34,代码来源:VoidExtractorTest.java

示例11: test10GetCountedProperties

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * Test method for VoidExtractor#getCountedProperties().
 * 0.nt
 */
@Test
public final void test10GetCountedProperties() {
    // set input file
    String inFile = "src/test/data/0.nt";
    // set expected result
    ObjectIntOpenHashMap<String> expected = new ObjectIntOpenHashMap<String>();
    expected.putOrAdd( "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", 2, 2 );
    expected.putOrAdd( "http://www.w3.org/2000/01/rdf-schema#label", 1, 1 );
    // run extraction
    try {
        // setup
        InputStream inStream = new FileInputStream( inFile );
        PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
        PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
        // run
        RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
        VoidExtractor extractor = new VoidExtractor();
        extractor.extract( iter );
        // print
        System.out.println( "0.nt:\n  PROPERTIES: " + extractor.getCountedProperties().toString() );
        // test
        assertEquals( expected, extractor.getCountedProperties() );
    }
    catch( Exception e ) {
        fail( e.toString() );
    }
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:32,代码来源:VoidExtractorTest.java

示例12: test15GetCountedProperties

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
/**
 * Test method for VoidExtractor#getCountedProperties().
 * 0.nt
 */
@Test
public final void test15GetCountedProperties() {
    // set input file
    String inFile = "src/test/data/5.nt";
    // set expected result
    ObjectIntOpenHashMap<String> expected = new ObjectIntOpenHashMap<String>();
    expected.putOrAdd( "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", 4, 4 );
    expected.putOrAdd( "http://example.org/property1", 0, 0 );
    expected.putOrAdd( "http://www.w3.org/2000/01/rdf-schema#subPropertyOf", 1, 1 );
    expected.putOrAdd( "http://www.w3.org/2000/01/rdf-schema#subClassOf", 1, 1 );
    expected.putOrAdd( "http://www.w3.org/2000/01/rdf-schema#label", 4, 4 );
    expected.putOrAdd( "http://example.org/property2", 0, 0 );
    // run extraction
    try {
        // setup
        InputStream inStream = new FileInputStream( inFile );
        PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
        PipedRDFStream<Triple> rdfStream = new PipedTriplesStream( iter );
        // run
        RDFDataMgr.parse(rdfStream,	inStream, "", RDFLanguages.resourceNameToLang( inFile ) );
        VoidExtractor extractor = new VoidExtractor();
        extractor.extract( iter );
        // print
        System.out.println( "5.nt:\n  PROPERTIES: " + extractor.getCountedProperties().toString() );
        // test
        assertEquals( expected, extractor.getCountedProperties() );
    }
    catch( Exception e ) {
        fail( e.toString() );
    }
}
 
开发者ID:dice-group,项目名称:Tapioca,代码行数:36,代码来源:VoidExtractorTest.java

示例13: main

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
public static void main(String[] args) {
        final String fileName = "data/Earthquakes-Spain-2013.ttl";		

        Sink<Triple> output = new SinkTripleOutput(System.out, null, SyntaxLabels.createNodeToLabel());
        PipedRDFIterator<Triple> iterator = new PipedRDFIterator<Triple>();
        final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iterator);

        //RDFDataMgr.parse(inputStream, fileName);
        
        // PipedRDFStream and PipedRDFIterator need to be on different threads
        ExecutorService executor = Executors.newSingleThreadExecutor();

        // Create a runnable for our parser thread
        Runnable parser = new Runnable() {

            @Override
            public void run() {
                // Call the parsing process.
                RDFDataMgr.parse(inputStream, fileName);
            }
        };

        // Start the parser on another thread
        executor.submit(parser);
        
//		
//		// Iterate over the data
        while (iterator.hasNext()) {
            Triple next = iterator.next();
            System.out.println("STRING: "+ next.toString());
            //output.send(next);
        }
        
        
    }
 
开发者ID:allaves,项目名称:storm-query-operators,代码行数:36,代码来源:TestRDFStreamSpout.java

示例14: main

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
public static void main(String[] args) {

      final String filename = "category_labels_en.ttl";

      // Create a PipedRDFStream to accept input and a PipedRDFIterator to
      // consume it
      // You can optionally supply a buffer size here for the
      // PipedRDFIterator, see the documentation for details about recommended
      // buffer sizes
      PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
      final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iter);

      // PipedRDFStream and PipedRDFIterator need to be on different threads
      ExecutorService executor = Executors.newSingleThreadExecutor();

      // Create a runnable for our parser thread
      Runnable parser = new Runnable() {

          public void run() {
              // Call the parsing process.
              RDFDataMgr.parse(inputStream, filename);
          }
      };

      // Start the parser on another thread
      executor.submit(parser);

      // We will consume the input on the main thread here

      // We can now iterate over data as it is parsed, parsing only runs as
      // far ahead of our consumption as the buffer size allows
      while (iter.hasNext()) {
          Triple next = iter.next();
          if (next.getObject().isLiteral()){
          	System.out.println(next.getObject().getLiteralLexicalForm());
          }
      }
  }
 
开发者ID:SaudAljaloud,项目名称:RdfLiteralStats,代码行数:39,代码来源:TestRiot.java

示例15: main

import org.apache.jena.riot.lang.PipedRDFStream; //导入依赖的package包/类
public static void main(String... argv) {
    final String filename = "data.ttl";

    // Create a PipedRDFStream to accept input and a PipedRDFIterator to
    // consume it
    // You can optionally supply a buffer size here for the
    // PipedRDFIterator, see the documentation for details about recommended
    // buffer sizes
    PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
    final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iter);

    // PipedRDFStream and PipedRDFIterator need to be on different threads
    ExecutorService executor = Executors.newSingleThreadExecutor();

    // Create a runnable for our parser thread
    Runnable parser = new Runnable() {

        @Override
        public void run() {
            // Call the parsing process.
            RDFDataMgr.parse(inputStream, filename);
        }
    };

    // Start the parser on another thread
    executor.submit(parser);

    // We will consume the input on the main thread here

    // We can now iterate over data as it is parsed, parsing only runs as
    // far ahead of our consumption as the buffer size allows
    while (iter.hasNext()) {
        Triple next = iter.next();
        // Do something with each triple
    }
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:37,代码来源:ExRIOT_6.java


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