我试图使用Protege3.x在本体中添加属性限制.
我在指定限制内的枚举时遇到问题.例如,尝试指定枚举以这种方式限制可能的数据元素:

它将整个表达式视为单个字符串:

在另一个例子中,我试图通过使用多个表达式和它们之间的"或"来解决问题,这似乎是合适的.但在前一个版本中,不允许使用"或".

如何使用枚举来满足这种需求?谢谢!
我是Jena和Owl的新手,我获得了本体论.我可以用Protege 4.2打开它而没有任何问题但是当我尝试用Jena打开它时我得到了:
Exception in thread "main" org.apache.jena.riot.RiotException: {E201} Multiple children of property element.
我一直在我的Ontology中查看它可能是什么,我注意到一些元素在一种语言中有多个Label,例如:
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">Sukralfat</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">antepsin</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal datatypeIRI="&xsd;string">sucralfate</Literal>
</AnnotationAssertion>
<AnnotationAssertion>
<AnnotationProperty abbreviatedIRI="rdfs:label"/>
<AbbreviatedIRI>atc:A02BX02</AbbreviatedIRI>
<Literal xml:lang="no" datatypeIRI="&rdf;PlainLiteral">sukralfat</Literal>
</AnnotationAssertion>
Run Code Online (Sandbox Code Playgroud)
这会导致问题吗?我使用的所有代码都与其他本体一起工作,所以我认为它真的来自这个本体.你知道什么可能导致这个例外吗?
所以我得到了一个最小化的案例,仍然得到同样的错误:
<?xml version="1.0"?>
<!DOCTYPE Ontology [
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY xml "http://www.w3.org/XML/1998/namespace" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
xml:base="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
ontologyIRI="http://www.ebi.ac.uk/Rebholz-srv/atc/public/ontologies/atc.owl">
<Prefix …Run Code Online (Sandbox Code Playgroud) 我无法在我的Ontology中表达以下情况:
假设我有四个人投票和四个投票(因此投票和选民之间存在一对一的映射).人们可以投票赞成或反对.如果我知道三人投票的结果,我应该能够推断出第四人的投票.
重申一下:约翰,鲍勃,玛丽和卡罗尔各自投票.由于有四个人有四票.投票结果是一个平局(2是,2没有).后来推理者确定Bob和John投了反对票.然后推理者应该能够推断出玛丽和卡罗尔的选票是肯定的.
目前我正在使用Jena的java api构建我的本体,并使用Jena推理器进行推理,所以我宁愿使用Jena支持的规则/语义.
我正在使用Protege开发一个本体,其中包含一些已在DBpedia中描述的内容.假设我想要包括一个"城市"课程,并将"柏林"作为个人.我的柏林将拥有柏林DBpedia所拥有的一些属性,但除此之外我还想"重用"DBpedia的柏林.
我是否需要定义自己的柏林然后使用rdf:seeAlso还是我可以以某种方式导入DBpedia的柏林并添加一些属性?
我有一个RDFS本体,有两个完全独立的类:User和Venue.我希望它们都具有通过被称为属性提供的名称hasName,对于a User应该看起来类似于:
<rdf:Property rdf:ID="hasName">
<rdfs:comment>
Comment here. Blah blah blah.
</rdfs:comment>
<rdfs:domain rdf:resource="#user"/>
<rdfs:range rdf:resource="Literal"/>
</rdf:Property>
Run Code Online (Sandbox Code Playgroud)
但是,如果我也想要它Venue,它不会验证.
我该怎么做呢?
我在使用与Jena的SPARQL查询时尝试以更易读的格式获取数据,但是我不知道如何以正确的方式提取数据.至于现在,输出是:
" http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#SaucelitoCanyon "
相反,我想把"SaucelitoCanyon"作为输出.
public JenaQuery() {
String wineRegion = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+ "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n"
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n"
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
+ "PREFIX wine:<http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>\n"
+ "SELECT ?region ?winery \n"
+ "WHERE {?wine wine:locatedIn ?region . \n"
+ "?region wine:locatedIn wine:CaliforniaRegion . \n"
+ "?wine wine:hasMaker ?winery}";
String inputFileName = "wine.rdf";
// create an empty model
Model model = ModelFactory.createDefaultModel();
// use the FileManager to find the input file
InputStream in;
in = FileManager.get().open(inputFileName);
if (in …Run Code Online (Sandbox Code Playgroud) 请参阅本书"语义Web技术的基础",第130页中的本体代码.
(本书的精选页面可在Google Books上找到.)
<Person rdf:about="anton">
<likesToWorkWith rdf:resource="doris" />
<likesToWorkWith rdf:resource="dagmar" />
</Person>
<Person rdf:about="doris">
<likesToWorkWith rdf:resource="dagmar" />
<likesToWorkWith rdf:resource="bernd" />
</Person>
<Person rdf:about="gustav">
<likesToWorkWith rdf:resource="bernd" />
<likesToWorkWith rdf:resource="doris" />
<likesToWorkWith rdf:resource="desiree" />
</Person>
<Person rdf:about="charles" />
<owl:Class rdf:about="FemaleColleagues">
<owl:oneOf rdf:parseType="Collection">
<Person rdf:about="dagmar" />
<Person rdf:about="doris" />
<Person rdf:about="desiree" />
</owl:oneOf>
</owl:Class>
<owl:AllDifferent>
<owl:distinctMembers
rdf:parseType="Collection">
<Person rdf:about="anton" />
<Person rdf:about="bernd" />
<Person rdf:about="charles" />
<Person rdf:about="dagmar" />
<Person rdf:about="desiree" />
<Person rdf:about="doris" />
</owl:distinctMembers>
</owl:AllDifferent>
Run Code Online (Sandbox Code Playgroud)
现在,在同一本书的第132页中,Class2 …
根据gate.ac.uk,地名词典是:
地名词典由一组列表组成,这些列表包含诸如城市,组织,星期几等实体的名称。这些列表用于查找文本中这些名称的出现,例如,用于命名实体的识别任务。“地名词典”一词通常既可用于实体列表集,又可用于处理资源,该资源使用这些列表来查找文本中名称的出现。
这与“本体论”有何不同?
如何使用owlapi从加载的本体中获取所有类?在这里,我有一个关于如何获取一个类的示例,但是我对访问本体中定义的所有类感兴趣。
OWLOntologyManager manager = WLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntology(IRI.create(fileURI));
OWLDataFactory owlDF = manager.getOWLDataFactory();
//Example to get ONE class, but I want ALL!
OWLClass stringDocuClass = owlDF.getOWLClass(IRI.create("http://example.com/my_ontology.owl#StringDocu"));
Run Code Online (Sandbox Code Playgroud)
我正在使用Java owlapi 4.2.3(请参阅API:http ://owlapi.sourceforge.net/javadoc/ )
我尝试将一个人插入我的本体,但得到错误:
Error 400: SPARQL Query: No 'query=' parameter
Fuseki - version 2.4.1 (Build date: 2016-11-04T18:59:20+0000)
Run Code Online (Sandbox Code Playgroud)
这是我的SPARQL INSERT查询#1:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX oo: <http://www.test.com/test-ontology.owl#>
INSERT {
oo:cap_123 rdf:type oo:MyTours .
oo:cap_123 oo:active true .
oo:cap_123 oo:title 'Text text text' .
}
WHERE {
FILTER NOT EXISTS { oo:cap_123 rdf:type oo:MyTours .
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的INSERT查询#2:
INSERT DATA {
oo:cap_123 rdf:type oo:MyTours .
oo:cap_123 oo:active true .
oo:cap_123 oo:title 'Text text text' .
}
Run Code Online (Sandbox Code Playgroud)
如果我使用Protégé插入个体,那么它可以工作并保存结果,如下所示:
<owl:NamedIndividual rdf:about="http://www.test.com/test-ontology.owl#cap_123"> …Run Code Online (Sandbox Code Playgroud)