本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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));
}
}
示例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);
}
}