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


Java RDFHandler.handleNamespace方法代码示例

本文整理汇总了Java中org.openrdf.rio.RDFHandler.handleNamespace方法的典型用法代码示例。如果您正苦于以下问题:Java RDFHandler.handleNamespace方法的具体用法?Java RDFHandler.handleNamespace怎么用?Java RDFHandler.handleNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openrdf.rio.RDFHandler的用法示例。


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

示例1: propagateToHandler

import org.openrdf.rio.RDFHandler; //导入方法依赖的package包/类
private static void propagateToHandler(List<Statement> 
        statements, RDFHandler handler) 
        throws RDFHandlerException, RepositoryException{            
    handler.startRDF();	   
    handler.handleNamespace("rdf", 
            "http://www.w3.org/1999/02/22-rdf-syntax-ns#");			
    handler.handleNamespace("rdfs", 
            "http://www.w3.org/2000/01/rdf-schema#");			
    handler.handleNamespace("dcat", "http://www.w3.org/ns/dcat#");			
    handler.handleNamespace("xsd", "http://www.w3.org/2001/XMLSchema#");			
    handler.handleNamespace("owl", "http://www.w3.org/2002/07/owl#");			
    handler.handleNamespace("dct", "http://purl.org/dc/terms/");
    handler.handleNamespace("lang", 
            "http://id.loc.gov/vocabulary/iso639-1/");
    for(Statement st: statements){
        handler.handleStatement(st);            
    }  
    handler.endRDF();
}
 
开发者ID:DTL-FAIRData,项目名称:ODEX-FAIRDataPoint,代码行数:20,代码来源:RDFUtils.java

示例2: propagateToHandler

import org.openrdf.rio.RDFHandler; //导入方法依赖的package包/类
public static void propagateToHandler(Nanopub nanopub, RDFHandler handler)
		throws RDFHandlerException {
	handler.startRDF();
	String s = nanopub.getUri().toString();
	if (nanopub instanceof NanopubWithNs && !((NanopubWithNs) nanopub).getNsPrefixes().isEmpty()) {
		NanopubWithNs np = (NanopubWithNs) nanopub;
		for (String p : np.getNsPrefixes()) {
			handler.handleNamespace(p, np.getNamespace(p));
		}
	} else {
		handler.handleNamespace("this", s);
		handler.handleNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
		handler.handleNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
		handler.handleNamespace("rdfg", "http://www.w3.org/2004/03/trix/rdfg-1/");
		handler.handleNamespace("xsd", "http://www.w3.org/2001/XMLSchema#");
		handler.handleNamespace("owl", "http://www.w3.org/2002/07/owl#");
		handler.handleNamespace("dct", "http://purl.org/dc/terms/");
		handler.handleNamespace("dce", "http://purl.org/dc/elements/1.1/");
		handler.handleNamespace("pav", "http://purl.org/pav/");
		handler.handleNamespace("np", "http://www.nanopub.org/nschema#");
	}
	for (Statement st : getStatements(nanopub)) {
		handler.handleStatement(st);
	}
	handler.endRDF();
}
 
开发者ID:Nanopublication,项目名称:nanopub-java,代码行数:27,代码来源:NanopubUtils.java

示例3: propagate

import org.openrdf.rio.RDFHandler; //导入方法依赖的package包/类
public void propagate(RDFHandler handler, boolean doStardAndEnd) throws RDFHandlerException {
	if (doStardAndEnd) handler.startRDF();
	for (Pair<String,String> ns : namespaces) {
		handler.handleNamespace(ns.getLeft(), ns.getRight());
	}
	for (Statement st : statements) {
		handler.handleStatement(st);
	}
	if (doStardAndEnd) handler.endRDF();
}
 
开发者ID:trustyuri,项目名称:trustyuri-java,代码行数:11,代码来源:RdfFileContent.java

示例4: main

import org.openrdf.rio.RDFHandler; //导入方法依赖的package包/类
public static void main(final String... args) {

        try {
            // Parse command line
            final CommandLine cmd = CommandLine
                    .parser()
                    .withName("eval-converter")
                    .withHeader("Convert a tool output in the format used for the evaluation.")
                    .withOption("o", "output", "the output file", "FILE", Type.STRING, true,
                            false, true)
                    .withOption("f", "format", "the format (fred, pikes, gold)", "FMT",
                            Type.STRING, true, false, true)
                    .withOption("n", "replace-nominal",
                            "replaces nominal frames with association " //
                                    + " relations (for FRED compatibility)")
                    .withLogger(LoggerFactory.getLogger("eu.fbk")) //
                    .parse(args);

            // Extract options
            final String format = cmd.getOptionValue("f", String.class).trim().toLowerCase();
            final String outputFile = cmd.getOptionValue("o", String.class);
            final List<String> inputFiles = cmd.getArgs(String.class);
            final boolean replaceNominalFrames = cmd.hasOption("n");

            // Obtain the converter corresponding to the format specified
            Converter converter;
            if (format.equalsIgnoreCase("fred")) {
                converter = FRED_CONVERTER;
            } else if (format.equalsIgnoreCase("gold")) {
                converter = GOLD_CONVERTER;
            } else if (format.equalsIgnoreCase("pikes")) {
                converter = PIKES_CONVERTER;
            } else {
                throw new IllegalArgumentException("Unknown format: " + format);
            }

            // Read the input
            final Map<String, String> namespaces = Maps.newHashMap();
            final QuadModel input = QuadModel.create();
            RDFSources.read(false, false, null, null,
                    inputFiles.toArray(new String[inputFiles.size()])).emit(
                    RDFHandlers.wrap(input, namespaces), 1);

            // Perform the conversion
            final QuadModel output = converter.convert(input);

            // Replace nominal frames if requested
            if (replaceNominalFrames) {
                replaceNominalFrames(output);
            }

            // Write the output
            final RDFHandler out = RDFHandlers.write(null, 1000, outputFile);
            out.startRDF();
            namespaces.put(DCTERMS.PREFIX, DCTERMS.NAMESPACE);
            namespaces.put("pb", "http://pikes.fbk.eu/ontologies/propbank#");
            namespaces.put("nb", "http://pikes.fbk.eu/ontologies/nombank#");
            namespaces.put("vn", "http://pikes.fbk.eu/ontologies/verbnet#");
            namespaces.put("fn", "http://pikes.fbk.eu/ontologies/framenet#");
            namespaces.put("dul", "http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#");
            final Set<String> outputNS = Sets.newHashSet();
            collectNS(outputNS, output);
            for (final Map.Entry<String, String> entry : namespaces.entrySet()) {
                if (!entry.getKey().isEmpty() && outputNS.contains(entry.getValue())) {
                    out.handleNamespace(entry.getKey(), entry.getValue());
                }
            }
            for (final Statement stmt : Ordering.from(
                    Statements.statementComparator("cspo",
                            Statements.valueComparator(RDF.NAMESPACE))).sortedCopy(output)) {
                out.handleStatement(stmt);
            }
            out.endRDF();

        } catch (final Throwable ex) {
            // Display error information and terminate
            CommandLine.fail(ex);
        }
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:80,代码来源:Converter.java

示例5: main

import org.openrdf.rio.RDFHandler; //导入方法依赖的package包/类
public static void main(final String[] args) {

        try {
            // Parse command line
            final CommandLine cmd = CommandLine
                    .parser()
                    .withName("eval-aligner")
                    .withHeader("Alignes the knowledge graphs produced by different tools " //
                            + "againsts a gold graph")
                    .withOption("o", "output", "the output file", "FILE", Type.STRING, true,
                            false, true) //
                    .withLogger(LoggerFactory.getLogger("eu.fbk")) //
                    .parse(args);

            // Extract options
            final String outputFile = cmd.getOptionValue("o", String.class);
            final List<String> inputFiles = cmd.getArgs(String.class);

            // Read the input
            final Map<String, String> namespaces = Maps.newHashMap();
            final QuadModel input = QuadModel.create();
            RDFSources.read(false, false, null, null,
                    inputFiles.toArray(new String[inputFiles.size()])).emit(
                    RDFHandlers.wrap(input, namespaces), 1);

            // Perform the alignment
            final List<Statement> mappingStmts = align(input);
            input.addAll(mappingStmts);

            // Write the output
            final RDFHandler out = RDFHandlers.write(null, 1000, outputFile);
            out.startRDF();
            namespaces.put(DCTERMS.PREFIX, DCTERMS.NAMESPACE);
            for (final Map.Entry<String, String> entry : namespaces.entrySet()) {
                if (!entry.getKey().isEmpty()) {
                    out.handleNamespace(entry.getKey(), entry.getValue());
                }
            }
            for (final Statement stmt : Ordering.from(
                    Statements.statementComparator("cspo",
                            Statements.valueComparator(RDF.NAMESPACE))).sortedCopy(input)) {
                out.handleStatement(stmt);
            }
            out.endRDF();

        } catch (final Throwable ex) {
            // Display error information and terminate
            CommandLine.fail(ex);
        }
    }
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:51,代码来源:Aligner.java

示例6: addNamespaces

import org.openrdf.rio.RDFHandler; //导入方法依赖的package包/类
private void addNamespaces(RDFHandler handler) throws RDFHandlerException {
	for(String prefix:namespaces.getDeclaredPrefixes()) {
		handler.handleNamespace(prefix, namespaces.getNamespaceURI(prefix));
	}
}
 
开发者ID:ldp4j,项目名称:ldp4j,代码行数:6,代码来源:RDFModelFormater.java

示例7: handleNamespace

import org.openrdf.rio.RDFHandler; //导入方法依赖的package包/类
@Override
public void handleNamespace(String prefix, String uri) throws RDFHandlerException {
    for (RDFHandler rdfHandler : rdfHandlers) {
        rdfHandler.handleNamespace(prefix, uri);
    }
}
 
开发者ID:mifeet,项目名称:LD-FusionTool,代码行数:7,代码来源:FederatedRDFHandler.java


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