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


Java ParserConfig类代码示例

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


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

示例1: getResource

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
private Model getResource(UriBuilder uriBuilder) {
    RDFFormat format = RDFFormat.TURTLE;
    try {
        java.net.URI target = credentials.buildUrl(uriBuilder);
        log.debug("Exporting {} data from resource {}", format.getName(), target.toString());
        String entity = client.get(target, format.getDefaultMIMEType());
        return Rio.parse(new StringReader(entity), target.toString(), format, new ParserConfig(), ValueFactoryImpl.getInstance(), new ParseErrorLogger());
    } catch (IllegalArgumentException | URISyntaxException | RDFParseException | IOException e) {
        if (e instanceof ClientProtocolException && "Unexpected response status: 404".compareTo(e.getMessage())==0) {
            //keeping old behavior, should not be silently fail (i.e. return empty model)?
            return new LinkedHashModel();
        } else {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:redlink-gmbh,项目名称:redlink-java-sdk,代码行数:17,代码来源:RedLinkDataImpl.java

示例2: getParserConfig

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
private static ParserConfig getParserConfig() {
	ParserConfig config = new ParserConfig();

	Set<RioSetting<?>> aNonFatalErrors = Sets.<RioSetting<?>> newHashSet(
	                BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES);

	config.setNonFatalErrors(aNonFatalErrors);

	config.set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, false);
	config.set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, false);
	config.set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);
	config.set(BasicParserSettings.VERIFY_LANGUAGE_TAGS, false);
	config.set(BasicParserSettings.VERIFY_RELATIVE_URIS, false);

	return config;
}
 
开发者ID:clarkparsia,项目名称:csv2rdf,代码行数:17,代码来源:CSV2RDF.java

示例3: ExternalSortingInputLoader

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
/**
     * @param dataSources initialized {@link cz.cuni.mff.odcleanstore.fusiontool.loaders.data.AllTriplesLoader} loaders
     * @param cacheDirectory directory for temporary files
     * @param parserConfig RDF parser configuration
     * @param maxMemoryLimit maximum memory amount to use for large operations;
* if the limit is too high, it may cause OutOfMemory exceptions
     */
    public ExternalSortingInputLoader(
            Collection<AllTriplesLoader> dataSources,
            Set<URI> resourceDescriptionProperties,
            File cacheDirectory,
            ParserConfig parserConfig,
            long maxMemoryLimit) {

        checkNotNull(dataSources);
        checkNotNull(cacheDirectory);
        checkNotNull(resourceDescriptionProperties);
        this.dataSources = dataSources;
        this._resourceDescriptionProperties = resourceDescriptionProperties;
        this.maxMemoryLimit = maxMemoryLimit;
        this.cacheDirectory = cacheDirectory;
        this.parserConfig = parserConfig;
        this.externalSorter = new ExternalSorter(getSortComparator(), cacheDirectory, USE_GZIP, maxMemoryLimit);
    }
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:25,代码来源:ExternalSortingInputLoader.java

示例4: throwsExceptionOnParseError

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
@Test(expected = IOException.class)
public void throwsExceptionOnParseError() throws Exception {
    // Arrange
    String inputString = "<http://uri1> _bnode1 .\n";
    ByteArrayInputStream inputStream = new ByteArrayInputStream(inputString.getBytes());

    // Act
    NTuplesParser parser = new NTuplesParser(new InputStreamReader(inputStream), new ParserConfig());
    try {
        while (parser.hasNext()) {
            parser.next();
        }
    } finally {
        parser.close();
    }
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:17,代码来源:NTuplesParserTest.java

示例5: skipsErrorWhenFailOnNTriplesInvalidLinesSettingIsNonFatal

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
@Test
public void skipsErrorWhenFailOnNTriplesInvalidLinesSettingIsNonFatal() throws Exception {
    // Arrange
    String inputString = "<http://uri1> _:bnode1 abc.\n<http://uri2> <http://uri3>.\n";
    ByteArrayInputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
    ParserConfig parserConfig = new ParserConfig();
    parserConfig.addNonFatalError(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES);

    // Act
    NTuplesParser parser = new NTuplesParser(new InputStreamReader(inputStream), parserConfig);
    List<List<Value>> tuples = new ArrayList<>();
    try {
        while (parser.hasNext()) {
            tuples.add(parser.next());
        }
    } finally {
        parser.close();
    }

    // Assert
    assertThat(tuples, contains((List<Value>) ImmutableList.of((Value) LDFusionToolTestUtils.createHttpUri("uri2"), LDFusionToolTestUtils.createHttpUri("uri3"))));
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:23,代码来源:NTuplesParserTest.java

示例6: exportDataset

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
@Override
public Model exportDataset(String dataset) {
    RDFFormat format = RDFFormat.TURTLE;
    try {
        final java.net.URI target = credentials.buildUrl(getDatasetUriBuilder(dataset));
        log.debug("Exporting {} data from dataset {}", format.getName(), dataset);
        final String entity = client.get(target, format.getDefaultMIMEType());
        return Rio.parse(new StringReader(entity), target.toString(), format, new ParserConfig(), ValueFactoryImpl.getInstance(), new ParseErrorLogger());
    } catch (IllegalArgumentException | URISyntaxException | RDFParseException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:redlink-gmbh,项目名称:redlink-java-sdk,代码行数:13,代码来源:RedLinkDataImpl.java

示例7: AllTriplesFileLoader

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
/**
 * Creates a new instance.
 */
public AllTriplesFileLoader(DataSourceConfig dataSourceConfig, ParserConfig parserConfig) {
    Preconditions.checkNotNull(dataSourceConfig);
    Preconditions.checkNotNull(parserConfig);
    this.fileLoader = new RdfFileLoader(dataSourceConfig, parserConfig);
    this.paramReader = new OutputParamReader(dataSourceConfig);
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:10,代码来源:AllTriplesFileLoader.java

示例8: SameAsLinkFileLoader

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
public SameAsLinkFileLoader(SourceConfig sourceConfig, ParserConfig parserConfig, Set<URI> sameAsLinkTypes) {
    Preconditions.checkNotNull(sourceConfig);
    Preconditions.checkNotNull(parserConfig);
    Preconditions.checkNotNull(sameAsLinkTypes);
    this.fileLoader = new RdfFileLoader(sourceConfig, parserConfig);
    this.paramReader = new OutputParamReader(sourceConfig);
    this.sameAsLinkTypes = sameAsLinkTypes;
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:9,代码来源:SameAsLinkFileLoader.java

示例9: parsesCorrectlyAllValueTypes

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
@Test
public void parsesCorrectlyAllValueTypes() throws Exception {
    // Arrange
    String inputString =
            "<http://uri1> _:bnode1 \"literal\" \"123\"^^<http://www.w3.org/2001/XMLSchema#int> .\n" +
                    "<http://uri2> .\n" +
                    "<http://uri3> <http://uri4> .";
    ByteArrayInputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
    ParserConfig parserConfig = new ParserConfig();
    parserConfig.set(BasicParserSettings.PRESERVE_BNODE_IDS, true);

    // Act
    NTuplesParser parser = new NTuplesParser(new InputStreamReader(inputStream), parserConfig);
    List<List<Value>> result = new ArrayList<>();
    try {
        while (parser.hasNext()) {
            result.add(parser.next());
        }
    } finally {
        parser.close();
    }

    // Assert
    assertThat(result.get(0), is(Arrays.asList(
            VF.createURI("http://uri1"),
            VF.createBNode("bnode1"),
            VF.createLiteral("literal"),
            VF.createLiteral(123))));
    assertThat(result.get(1), is(Arrays.asList(
            (Value) VF.createURI("http://uri2"))));
    assertThat(result.get(2), is(Arrays.asList(
            (Value) VF.createURI("http://uri3"),
            VF.createURI("http://uri4"))));
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:35,代码来源:NTuplesParserTest.java

示例10: skipsCommentsAndNewlines

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
@Test
public void skipsCommentsAndNewlines() throws Exception {
    // Arrange
    String inputString = "<http://uri1> .\n"
            + "# comment\n"
            + "<http://uri2> .\n"
            + "\n\n\n"
            + "<http://uri3> .";
    ByteArrayInputStream inputStream = new ByteArrayInputStream(inputString.getBytes());
    ParserConfig parserConfig = new ParserConfig();
    parserConfig.set(BasicParserSettings.PRESERVE_BNODE_IDS, true);

    // Act
    NTuplesParser parser = new NTuplesParser(new InputStreamReader(inputStream), parserConfig);
    List<List<Value>> result = new ArrayList<>();
    try {
        while (parser.hasNext()) {
            result.add(parser.next());
        }
    } finally {
        parser.close();
    }

    // Assert
    assertThat(result.get(0), is(Arrays.asList((Value) VF.createURI("http://uri1"))));
    assertThat(result.get(1), is(Arrays.asList((Value) VF.createURI("http://uri2"))));
    assertThat(result.get(2), is(Arrays.asList((Value) VF.createURI("http://uri3"))));
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:29,代码来源:NTuplesParserTest.java

示例11: readRDF

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
public static void readRDF(final InputStream in, @Nullable final RDFFormat format,
        @Nullable final Map<String, String> namespaces, @Nullable final String base,
        final boolean preserveBNodes, final RDFHandler handler) throws IOException,
        RDFParseException, RDFHandlerException {

    final RDFParser parser = Rio.createParser(format);
    parser.setValueFactory(Data.getValueFactory());

    final ParserConfig config = parser.getParserConfig();
    config.set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
    config.set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true);
    config.set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);
    config.set(BasicParserSettings.VERIFY_LANGUAGE_TAGS, true);
    config.set(BasicParserSettings.VERIFY_RELATIVE_URIS, true);
    config.set(BasicParserSettings.NORMALIZE_DATATYPE_VALUES, true);
    config.set(BasicParserSettings.NORMALIZE_LANGUAGE_TAGS, true);
    config.set(BasicParserSettings.PRESERVE_BNODE_IDS, preserveBNodes);

    if (format.equals(RDFFormat.NTRIPLES)) {
        config.set(NTriplesParserSettings.FAIL_ON_NTRIPLES_INVALID_LINES, true);

    } else if (format.equals(RDFFormat.JSONLD)) {
        // following parameters are currently ignored by used library
        config.set(JSONLDSettings.COMPACT_ARRAYS, true);
        config.set(JSONLDSettings.OPTIMIZE, true);
        config.set(JSONLDSettings.USE_NATIVE_TYPES, false);
        config.set(JSONLDSettings.USE_RDF_TYPE, false);
        config.set(JSONLDSettings.JSONLD_MODE, JSONLDMode.COMPACT);

    } else if (format.equals(RDFFormat.RDFJSON)) {
        config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_DATATYPES, true);
        config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_LANGUAGES, true);
        config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_TYPES, true);
        config.set(RDFJSONParserSettings.FAIL_ON_MULTIPLE_OBJECT_VALUES, true);
        config.set(RDFJSONParserSettings.FAIL_ON_UNKNOWN_PROPERTY, true);
        config.set(RDFJSONParserSettings.SUPPORT_GRAPHS_EXTENSION, true);

    } else if (format.equals(RDFFormat.TRIX)) {
        config.set(TriXParserSettings.FAIL_ON_TRIX_INVALID_STATEMENT, true);
        config.set(TriXParserSettings.FAIL_ON_TRIX_MISSING_DATATYPE, false);

    } else if (format.equals(RDFFormat.RDFXML)) {
        config.set(XMLParserSettings.FAIL_ON_DUPLICATE_RDF_ID, true);
        config.set(XMLParserSettings.FAIL_ON_INVALID_NCNAME, true);
        config.set(XMLParserSettings.FAIL_ON_INVALID_QNAME, true);
        config.set(XMLParserSettings.FAIL_ON_MISMATCHED_TAGS, true);
        config.set(XMLParserSettings.FAIL_ON_NON_STANDARD_ATTRIBUTES, false);
        config.set(XMLParserSettings.FAIL_ON_SAX_NON_FATAL_ERRORS, false);
    }

    if (namespaces != null && parser instanceof RDFParserBase) {
        try {
            final Field field = RDFParserBase.class.getDeclaredField("namespaceTable");
            field.setAccessible(true);
            field.set(parser, Data.newNamespaceMap(Data.newNamespaceMap(), namespaces));
        } catch (final Throwable ex) {
            // ignore
            ex.printStackTrace();
        }
    }

    parser.setRDFHandler(handler);
    parser.parse(in, Strings.nullToEmpty(base));
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:65,代码来源:RDFUtil.java

示例12: readAll

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
public void readAll(String inputFileName) throws IOException, RDFParseException, RDFHandlerException {
    File inFile = new File(inputFileName);
    ParserConfig config = new ParserConfig();
    org.openrdf.repository.util.RDFLoader loader = new org.openrdf.repository.util.RDFLoader(config, vf);
    loader.load(inFile, _currentNamespace, RDFFormat.TURTLE, this);
}
 
开发者ID:ale003,项目名称:testGraphDbs,代码行数:7,代码来源:RdfReadHandler.java

示例13: getParserConfig

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
@Override
public ParserConfig getParserConfig() {
    return parserConfig;
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:5,代码来源:ConfigImpl.java

示例14: NQuadsParserIterator

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
public NQuadsParserIterator(Reader inputReader, ParserConfig parserConfig) throws IOException {
    this.internalParser = new Parser(inputReader, parserConfig);
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:4,代码来源:NQuadsParserIterator.java

示例15: Parser

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
public Parser(Reader inputReader, ParserConfig parserConfig) throws IOException {
    this.reader = inputReader;
    initialize();
    this.setParserConfig(parserConfig);
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:6,代码来源:NQuadsParserIterator.java


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