001package org.dllearner.algorithms.qtl.util.vocabulary; 002 003import com.google.common.collect.Sets; 004import org.apache.jena.rdf.model.Property; 005import org.apache.jena.rdf.model.Resource; 006import org.apache.jena.rdf.model.ResourceFactory; 007import org.apache.jena.shared.PrefixMapping; 008import org.apache.jena.sparql.serializer.SerializationContext; 009import org.apache.jena.sparql.vocabulary.FOAF; 010 011import java.util.Collections; 012import java.util.Set; 013 014/** 015 * @author Lorenz Buehmann 016 */ 017public class DBpedia { 018 019 // These will use ResourceFactory which creates Resource etc without a specific model. 020 // This is safer for complex initialization paths. 021 protected static final Resource resource(String uri ) 022 { return ResourceFactory.createResource( NS+uri ); } 023 024 protected static final Property property(String uri ) 025 { return ResourceFactory.createProperty( NS, uri ); } 026 027 /** The namespace of the vocabulary as a string. */ 028 public static final String NS = "http://dbpedia.org/"; 029 030 /** The namespace of the mapping based properties as a string. */ 031 public static final String DBO = "http://dbpedia.org/ontology/"; 032 033 /** The namespace of the raw infobox properties as a string. */ 034 public static final String DBP = "http://dbpedia.org/property/"; 035 036 /** The namespace of the resources vocabulary as a string. */ 037 public static final String DBR = "http://dbpedia.org/resource/"; 038 039 /** The namespace of the categories as a string. */ 040 public static final String DBC = "http://dbpedia.org/resource/Category:"; 041 042 /** The namespace of the vocabulary as a string */ 043 public static String getURI() {return NS;} 044 045 /** The namespace of the vocabulary as a resource */ 046 public static final Resource NAMESPACE = ResourceFactory.createResource( NS ); 047 048 /** 049 * Some properties (<code>http://dbpedia.org/ontology/wiki*</code>) which are usually blacklisted in applications. 050 */ 051 public static final Set<String> BLACKLIST_PROPERTIES = Collections.unmodifiableSet(Sets.newHashSet( 052 "http://dbpedia.org/ontology/wikiPageWikiLink", 053 "http://dbpedia.org/ontology/wikiPageExternalLink", 054 "http://dbpedia.org/ontology/wikiPageRedirects", 055 "http://dbpedia.org/ontology/wikiPageDisambiguates", 056 "http://dbpedia.org/ontology/wikiPageEditLink", 057 "http://dbpedia.org/ontology/wikiPageHistoryLink", 058 "http://dbpedia.org/ontology/wikiPageInterLanguageLink", 059 "http://dbpedia.org/ontology/wikiPageRevisionLink", 060 "http://dbpedia.org/ontology/wikiPageWikiLinkText", 061 "http://dbpedia.org/ontology/wikidataSplitIri", 062 "http://dbpedia.org/ontology/abstract", 063 "http://www.w3.org/ns/prov#wasDerivedFrom", 064 FOAF.isPrimaryTopicOf.getURI() 065 )); 066 067 public static final String BASE_IRI = "http://dbpedia.org/resource/"; 068 public static final PrefixMapping PM = PrefixMapping.Factory.create(); 069 static { 070 PM.setNsPrefixes(PrefixMapping.Standard); 071 PM.setNsPrefix("dbr", DBR); 072 PM.setNsPrefix("dbo", DBO); 073 PM.setNsPrefix("dbp", DBP); 074 PM.setNsPrefix("dbc", DBC); 075 PM.setNsPrefix("foaf", FOAF.NS); 076 } 077 public static final SerializationContext CONTEXT = new SerializationContext(PM); 078 static { 079 CONTEXT.setBaseIRI(BASE_IRI); 080 } 081 082}