• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ParserConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: NTuplesFileMerger

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


示例17: NTuplesParser

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


示例18: RepositoryFactory

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


示例19: mergesMatchingRecords

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
@Test
public void mergesMatchingRecords() throws Exception {
    String leftInputStr = "<http://a> <http://a1> .\n" +
            "<http://b> <http://b1> .\n" +
            "<http://d> <http://d1> .\n" +
            "<http://e> <http://e1> .\n" +
            "<http://e> <http://e2> .\n" +
            "<http://f> <http://f1> .\n" +
            "<http://f> <http://f2> .\n";
    String rightInputStr = "<http://b> <http://b1> .\n" +
            "<http://c> <http://c1> .\n" +
            "<http://d> <http://d1> .\n" +
            "<http://d> <http://d2> .\n" +
            "<http://e> <http://e1> .\n" +
            "<http://f> <http://f1> .\n" +
            "<http://f> <http://f2> .\n";
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    InputStream leftInput = new ByteArrayInputStream(leftInputStr.getBytes());
    InputStream rightInput = new ByteArrayInputStream(rightInputStr.getBytes());

    // Act
    NTuplesFileMerger merger = new NTuplesFileMerger(transform, new ParserConfig());
    merger.merge(new InputStreamReader(leftInput), new InputStreamReader(rightInput), new OutputStreamWriter(output));

    // Assert
    String expectedOutput = "<http://b> <http://b1> <http://b> <http://b1> .\n" +
            "<http://d> <http://d1> <http://d> <http://d1> .\n" +
            "<http://d> <http://d1> <http://d> <http://d2> .\n" +
            "<http://e> <http://e1> <http://e> <http://e1> .\n" +
            "<http://e> <http://e2> <http://e> <http://e1> .\n" +
            "<http://f> <http://f1> <http://f> <http://f1> .\n" +
            "<http://f> <http://f1> <http://f> <http://f2> .\n" +
            "<http://f> <http://f2> <http://f> <http://f1> .\n" +
            "<http://f> <http://f2> <http://f> <http://f2> .\n";
    NTuplesParser outputParser = new NTuplesParser(new InputStreamReader(new ByteArrayInputStream(output.toByteArray())), new ParserConfig());
    NTuplesParser expectedOutputParser = new NTuplesParser(new InputStreamReader(new ByteArrayInputStream(expectedOutput.getBytes())), new ParserConfig());
    while (outputParser.hasNext() || expectedOutputParser.hasNext()) {
        assertThat(outputParser.hasNext(), is(expectedOutputParser.hasNext()));
        assertThat(outputParser.next(), is(expectedOutputParser.next()));
    }
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:42,代码来源:NTuplesFileMergerTest.java


示例20: getParserConfig

import org.openrdf.rio.ParserConfig; //导入依赖的package包/类
/**
 * Returns configuration for Sesame file parsers.
 * @return configuration for Sesame file parsers
 */
ParserConfig getParserConfig();
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:6,代码来源:ConfigProcessing.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityTNTPrimed类代码示例发布时间:2022-05-23
下一篇:
Java CstBaseMethodRef类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap