Protege中的某些Ontology导入中并不总是显示前缀

时间:2017-08-19 13:51:43

标签: ontology prefix protege

有人可以解释为什么Protégé(5.2)会为某些类添加前缀而某些类没有?视图设置为短IRI名称。

我看到foaf:Agentdcterm:Agentgeo:SpatialThing。但是没有bio:Event,只有Event

这是本体论:

@prefix : <http://www.semanticweb.org/anato/ontologies/2017/7/untitled-ontology-210#> .
@prefix bio: <http://purl.org/vocab/bio/0.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://www.semanticweb.org/anato/ontologies/2017/7/untitled-ontology-210> a owl:Ontology ;
    owl:imports <http://purl.org/vocab/bio/0.1/> , <http://www.w3.org/2006/time#2016> , <http://xmlns.com/foaf/0.1/> .
# 
# 
# #################################################################
# #
# #    Classes
# #
# #################################################################
# 
# 
# http://xmlns.com/foaf/0.1/Person

foaf:Person a owl:Class .
# 
# Generated by the OWL API (version 4.2.6.20160910-2108) https://github.com/owlcs/owlapi

1 个答案:

答案 0 :(得分:2)

如果您想查看前缀,请选择查看&gt;以前缀名称呈现。
也许您应该在 Active Ontology&gt;上输入这些前缀。本体前缀首先。

问题应该是:为什么即使 View&gt;也会显示前缀选择实体IRI短名称

看起来很奇怪,但根据source code,即使在短名称渲染模式下,Protégé也应该显示一些前缀:

public String render(IRI iri) {
    try {
        String wellKnownName = wellKnownRenderings.get(iri);
        if(wellKnownName != null) {
            return wellKnownName;
        }
        String iriString = iri.toString();
        for(Namespaces ns : Namespaces.values()) {
            if(iriString.startsWith(ns.getPrefixIRI())) {
                return ns.getPrefixName() + ":" + iriString.substring(ns.getPrefixIRI().length());
            }
        }
        String fragment = getSubstringFromLastCharacter(iriString, '#');
        if(fragment != null) {
            return fragment;
        }
        String pathElement = getSubstringFromLastCharacter(iriString, '/');
        if(pathElement != null) {
            return pathElement;
        }
        return RenderingEscapeUtils.getEscapedRendering(iri.toQuotedString());
    }
    catch (Exception e) {
        return "<Error! " + e.getMessage() + ">";
    }
}

在确定是否应显示前缀时,Protégé依赖于this list

public enum Namespaces {
/** The OWL 2 namespace. */    OWL2        ("owl2",     "http://www.w3.org/2006/12/owl2#",      Status.LEGACY),
/** Status.LEGACY. */          OWL11XML    ("owl11xml", "http://www.w3.org/2006/12/owl11-xml#", Status.LEGACY),
/** The OWL 1.1 namespace. */  OWL11       ("owl11",    "http://www.w3.org/2006/12/owl11#",     Status.LEGACY),
/**The OWL namespace. */       OWL         ("owl",      "http://www.w3.org/2002/07/owl#", IN_USE),
/**The RDFS namespace. */      RDFS        ("rdfs",     "http://www.w3.org/2000/01/rdf-schema#", IN_USE),
/** The RDF namespace. */      RDF         ("rdf",      "http://www.w3.org/1999/02/22-rdf-syntax-ns#", IN_USE),
/** The XSD namespace. */      XSD         ("xsd",      "http://www.w3.org/2001/XMLSchema#",           IN_USE),
/** The XML namespace. */      XML         ("xml",      "http://www.w3.org/XML/1998/namespace"),
/** The SWRL namespace. */     SWRL        ("swrl",     "http://www.w3.org/2003/11/swrl#"),
/** The SWRLB namespace. */    SWRLB       ("swrlb",    "http://www.w3.org/2003/11/swrlb#"),
/** The SKOS namespace. */     SKOS        ("skos",     "http://www.w3.org/2004/02/skos/core#"),

// Further namespaces from the RDFa Core Initial Context
// http://www.w3.org/2011/rdfa-context/rdfa-1.1
/** The GRDDL namespace. */    GRDDL       ("grddl",    "http://www.w3.org/2003/g/data-view#"),
/** The MA namespace. */       MA          ("ma",       "http://www.w3.org/ns/ma-ont#"),
/** The PROV namespace. */     PROV        ("prov",     "http://www.w3.org/ns/prov#"),
/** The RDFA namespace. */     RDFA        ("rdfa",     "http://www.w3.org/ns/rdfa#"),
/** The RIF namespace. */      RIF         ("rif",      "http://www.w3.org/2007/rif#"),
/** The R2RML namespace. */    R2RML       ("rr",       "http://www.w3.org/ns/r2rml#"),
/** The SD namespace. */       SD          ("sd",       "http://www.w3.org/ns/sparql-service-description#"),
/** The SKOSXL namespace. */   SKOSXL      ("skosxl",   "http://www.w3.org/2008/05/skos-xl#"),
/** The POWDER namespace. */   POWDER      ("wdr",      "http://www.w3.org/2007/05/powder#"),
/** The VOID namespace. */     VOID        ("void",     "http://rdfs.org/ns/void#"),
/** The POWDERS namespace. */  POWDERS     ("wdrs",     "http://www.w3.org/2007/05/powder-s#"),
/** The XHV namespace. */      XHV         ("xhv",      "http://www.w3.org/1999/xhtml/vocab#"),
/** The ORG namespace. */      ORG         ("org",      "http://www.w3.org/ns/org#"),
/** The GLDP namespace. */     GLDP        ("gldp",     "http://www.w3.org/ns/people#"),
/** The CNT namespace. */      CNT         ("cnt",      "http://www.w3.org/2008/content#"),
/** The DCAT namespace. */     DCAT        ("dcat",     "http://www.w3.org/ns/dcat#"),
/** The EARL namespace. */     EARL        ("earl",     "http://www.w3.org/ns/earl#"),
/** The HT namespace. */       HT          ("ht",       "http://www.w3.org/2006/http#"),
/** The PTR namespace. */      PTR         ("ptr",      "http://www.w3.org/2009/pointers#"),

// Other widely used Semantic Web prefixes
/** The CC namespace. */       CC          ("cc",       "http://creativecommons.org/ns#"),
/** The CTAG namespace. */     CTAG        ("ctag",     "http://commontag.org/ns#"),
/** The DCTERMS namespace. */  DCTERMS     ("dcterms",  "http://purl.org/dc/terms/"),
/** The DC namespace. */       DC          ("dc",       "http://purl.org/dc/elements/1.1/"),
/** The FOAF namespace. */     FOAF        ("foaf",     "http://xmlns.com/foaf/0.1/"),
/** The GR namespace. */       GR          ("gr",       "http://purl.org/goodrelations/v1#"),
/** The ICAL namespace. */     ICAL        ("ical",     "http://www.w3.org/2002/12/cal/icaltzd#"),
/** The OG namespace. */       OG          ("og",       "http://ogp.me/ns#"),
/** The REV namespace. */      REV         ("rev",      "http://purl.org/stuff/rev#"),
/** The SIOC namespace. */     SIOC        ("sioc",     "http://rdfs.org/sioc/ns#"),
/** The VCARD namespace. */    VCARD       ("vcard",    "http://www.w3.org/2006/vcard/ns#"),
/** The SCHEMA namespace. */   SCHEMA      ("schema",   "http://schema.org/"),
/** The GEO namespace. */      GEO         ("geo",      "http://www.w3.org/2003/01/geo/wgs84_pos#"),
/** The SC namespace. */       SC          ("sc",       "http://purl.org/science/owl/sciencecommons/"),
/** The FB namespace. */       FB          ("fb",       "http://rdf.freebase.com/ns/",                 Status.LEGACY),
/** The GEONAMES namespace. */ GEONAMES    ("geonames", "http://www.geonames.org/ontology#",           Status.LEGACY),

// DBpedia
/** The DBPEDIA namespace. */  DBPEDIA     ("dbpedia", "http://dbpedia.org/resource/"),
/** The DBP namespace. */      DBP         ("dbp",     "http://dbpedia.org/property/"),
/** The DBO namespace. */      DBO         ("dbo",     "http://dbpedia.org/ontology/"),
/** The YAGO namespace. */     YAGO        ("yago",    "http://dbpedia.org/class/yago/");
//...

如您所见,此列表中包含foaf:dcterms:geo:,但bio:不是。

为了进行比较,这是{em> View&gt;时执行的how渲染。选择以前缀名称渲染:

public String render(IRI iri) {
    try {
        String s = prefixManager.getPrefixIRI(iri);
        if (s != null) {
            return s;
        }
        else {
            // No mapping
            return iri.toQuotedString();
        }
    }
    catch (Exception e) {
        return "<Error! " + e.getMessage() + ">";
    }
}