org.openrdf.rio.Rio.createParser()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.openrdf.rio.Rio.createParser方法的一些代码示例,展示了Rio.createParser的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rio.createParser方法的具体详情如下:
包路径:org.openrdf.rio.Rio
类名称:Rio
方法名:createParser

Rio.createParser介绍

[英]Convenience methods for creating RDFParser objects. This method uses the registry returned by RDFParserRegistry#getInstance() to get a factory for the specified format and uses this factory to create the appropriate parser.
[中]

代码示例

代码示例来源:origin: blazegraph/database

/**
 * Choose the parser based on the {@link RDFFormat} specified to the
 * constructor.
 * 
 * @return The parser.
 */
final protected RDFParser getParser(final RDFFormat rdfFormat) {
  final RDFParser parser = Rio.createParser(rdfFormat, valueFactory);
  
  parser.setValueFactory(valueFactory);
  
  return parser;
}

代码示例来源:origin: org.openprovenance.prov/prov-rdf

/** Parse from input stream, no base uri specified. */
public Document parseRDF(InputStream inputStream,
             RDFFormat format, 
             String baseuri)
                 throws RDFParseException,
                 RDFHandlerException,
                 IOException {
  RDFParser rdfParser = Rio.createParser(format);
  return parseRDF(inputStream, rdfParser, baseuri);
}

代码示例来源:origin: net.fortytwo/linked-data-sail

public VerbatimRdfizer(final RDFFormat format,
            final RDFParser.DatatypeHandling datatypeHandling) {
  this.format = format;
  parser = Rio.createParser(format);
  parser.setDatatypeHandling(datatypeHandling);
}

代码示例来源:origin: joshsh/ripple

public VerbatimRdfizer(final RDFFormat format,
            final RDFParser.DatatypeHandling datatypeHandling) {
  this.format = format;
  parser = Rio.createParser(format);
  parser.setDatatypeHandling(datatypeHandling);
}

代码示例来源:origin: lucmoreau/ProvToolbox

/** Parse from input stream, no base uri specified. */
public Document parseRDF(InputStream inputStream,
             RDFFormat format, 
             String baseuri)
                 throws RDFParseException,
                 RDFHandlerException,
                 IOException {
  RDFParser rdfParser = Rio.createParser(format);
  return parseRDF(inputStream, rdfParser, baseuri);
}

代码示例来源:origin: com.blazegraph/bigdata-core

/**
 * Choose the parser based on the {@link RDFFormat} specified to the
 * constructor.
 * 
 * @return The parser.
 */
final protected RDFParser getParser(final RDFFormat rdfFormat) {
  final RDFParser parser = Rio.createParser(rdfFormat, valueFactory);
  
  parser.setValueFactory(valueFactory);
  
  return parser;
}

代码示例来源:origin: org.openprovenance.prov/prov-rdf

public Document parseRDF(String filename) throws RDFParseException, RDFHandlerException,
                     IOException, JAXBException {
  // System.out.println("**** Parse "+filename);
  File file = new File(filename);
  URL documentURL = file.toURI().toURL();
  InputStream inputStream = documentURL.openStream();
  RDFParser rdfParser = Rio.createParser(Rio.getParserFormatForFileName(file.getName()));
  String streamName = documentURL.toString();
  return parseRDF(inputStream, rdfParser, streamName);
}

代码示例来源:origin: lucmoreau/ProvToolbox

public Document parseRDF(String filename) throws RDFParseException, RDFHandlerException,
                     IOException, JAXBException {
  // System.out.println("**** Parse "+filename);
  File file = new File(filename);
  URL documentURL = file.toURI().toURL();
  InputStream inputStream = documentURL.openStream();
  RDFParser rdfParser = Rio.createParser(Rio.getParserFormatForFileName(file.getName()));
  String streamName = documentURL.toString();
  return parseRDF(inputStream, rdfParser, streamName);
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-quest-sesame

public RepositoryConnection(SesameAbstractRepo rep, QuestDBConnection connection) throws OBDAException
{
  this.repository = rep;
  this.questConn = connection;
  this.isOpen = true;
  this.isActive = false;
  this.autoCommit = connection.getAutoCommit();
  this.rdfParser = Rio.createParser(RDFFormat.RDFXML,
      this.repository.getValueFactory());
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-obdalib-r2rml

/**
 * Constructor to start parsing R2RML mappings from file.
 * @param file - the File object
 */
public R2RMLManager(File file) throws Exception {
    myModel = new LinkedHashModel();			
    RDFParser parser = Rio.createParser(RDFFormat.TURTLE);
    InputStream in = new FileInputStream(file);
    URL documentUrl = new URL("file://" + file);
    StatementCollector collector = new StatementCollector(myModel);
    parser.setRDFHandler(collector);
    parser.parse(in, documentUrl.toString());
    r2rmlParser = new R2RMLParser();
}

代码示例来源:origin: org.apache.marmotta/marmotta-loader-core

/**
 * Creates a new RDFParserBase that will use a {@link org.openrdf.model.impl.ValueFactoryImpl} to
 * create RDF model objects.
 */
public GeonamesParser() {
  super();
  lineParser = Rio.createParser(RDFFormat.RDFXML);
  lineParser.setParseErrorListener(this);
  lineParser.setParserConfig(getParserConfig());
}

代码示例来源:origin: apache/marmotta

/**
 * Creates a new RDFParserBase that will use a {@link org.openrdf.model.impl.ValueFactoryImpl} to
 * create RDF model objects.
 */
public GeonamesParser() {
  super();
  lineParser = Rio.createParser(RDFFormat.RDFXML);
  lineParser.setParseErrorListener(this);
  lineParser.setParserConfig(getParserConfig());
}

代码示例来源:origin: uk.org.mygrid.resources/boca-core

public static void loadDataset(IDataset dataset, InputStream rdf, RDFFormat format,String baseURI,int batchSize) throws Exception {
  DatasetStatementCollection sc = new DatasetStatementCollection(batchSize,dataset);
  RDFParser parser = Rio.createParser(format);
  parser.setRDFHandler(sc);
  parser.setValueFactory(Constants.valueFactory);
  parser.parse(rdf,baseURI);
}

代码示例来源:origin: org.apache.marmotta/marmotta-loader-core

/**
 * Creates a new RDFParserBase that will use the supplied ValueFactory to
 * create RDF model objects.
 *
 * @param valueFactory A ValueFactory.
 */
public GeonamesParser(ValueFactory valueFactory) {
  super(valueFactory);
  lineParser = Rio.createParser(RDFFormat.RDFXML);
  lineParser.setParseErrorListener(this);
  lineParser.setValueFactory(valueFactory);
  lineParser.setParserConfig(getParserConfig());
}

代码示例来源:origin: joshsh/ripple

public static void parse(final InputStream is,
               final RDFSink sink,
               final String baseUri,
               final RDFFormat format) throws RippleException {
    RDFParser parser = Rio.createParser(format);
    parser.setRDFHandler(new SesameInputAdapter(sink));

    try {
      parser.parse(is, baseUri);
    } catch (IOException | RDFParseException | RDFHandlerException e) {
      throw new RippleException(e);
    }
  }
}

代码示例来源:origin: org.openrdf.sesame/sesame-sail-spin

@Override
protected void addAxiomStatements()
  throws SailException
{
  RDFParser parser = Rio.createParser(RDFFormat.TURTLE);
  if (axiomClosureNeeded) {
    loadAxiomStatements(parser, "/schema/spin-full.ttl");
  }
  else {
    loadAxiomStatements(parser, "/schema/sp.ttl");
    loadAxiomStatements(parser, "/schema/spin.ttl");
    loadAxiomStatements(parser, "/schema/spl.spin.ttl");
  }
}

代码示例来源:origin: org.apache.marmotta/marmotta-loader-core

/**
 * Create a parser for the given format, turning off some of the stricter configuration settings so we
 * can handle more messy data without errors.
 * @param format
 * @return
 */
private RDFParser createParser(RDFFormat format) {
  RDFParser parser = Rio.createParser(format);
  parser.getParserConfig().addNonFatalError(BasicParserSettings.VERIFY_DATATYPE_VALUES);
  parser.getParserConfig().addNonFatalError(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES);
  parser.getParserConfig().addNonFatalError(BasicParserSettings.NORMALIZE_DATATYPE_VALUES);
  return parser;
}

代码示例来源:origin: synchrony/smsn

private long parseRdfContent(final InputStream content,
               final RDFFormat format) throws RDFParseException, IOException, RDFHandlerException {
  RDFParser parser = Rio.createParser(format);
  parser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);
  ParsedRDFHandler parsedRDFHandler = new ParsedRDFHandler();
  parsedRDFHandler.clear();
  parser.setRDFHandler(parsedRDFHandler);
  parser.parse(content, BASE_IRI);
  return parsedRDFHandler.getCount();
}

代码示例来源:origin: com.github.ansell.sesame-rio-extensions/sesame-rio-extensions-rdfjson

@Test
public void testParserFactoryRegisteredAlternate()
{
  final RDFFormat fmt = Rio.getParserFormatForMIMEType("application/json");
  Assert.assertNotNull("Could not find the RDF/JSON RDFFormat instance", fmt);
  final RDFParser parser = Rio.createParser(fmt);
  Assert.assertTrue(parser instanceof RDFJSONParser);
}

代码示例来源:origin: com.github.ansell.sesame-rio-extensions/sesame-rio-extensions-rdfjson

@Test
public void testParserFactoryRegistered()
{
  final RDFFormat fmt = Rio.getParserFormatForMIMEType("application/rdf+json");
  Assert.assertNotNull("Could not find the RDF/JSON RDFFormat instance", fmt);
  final RDFParser parser = Rio.createParser(fmt);
  Assert.assertTrue(parser instanceof RDFJSONParser);
}

相关文章