以下是我在N3中创建类的方法:
:Person a rdfs:Class.
Run Code Online (Sandbox Code Playgroud)
以下是如何指定特定的ressource是该类的实例:
:Pat a :Person.
Run Code Online (Sandbox Code Playgroud)
问题:我想创建一个包含20000多个实例的类(以编程方式生成).:Pat a :Person.为我的20000个实例编写整体使得本体文件变得冗长.
问题:是否有解决方案使文件变小?
我现在正在研究一个项目,我需要一些帮助.
基本上,我需要将以下RDF转换为Java类的表示.我把RDF读到一个模型,从那里我被卡住了.
StringReader in = new StringReader(resultTemp);
Model model = ModelFactory.createDefaultModel();
model.read(in, null, "TURTLE");
Run Code Online (Sandbox Code Playgroud)
我尝试使用函数listSubjectsWithProperty(属性arg0,RDFNode arg1)和StmtIterator,但我无法弄明白.我非常感谢一些帮助.
RDF:
@prefix d: <http://www.w3.org/2001/XMLSchema#> .
@prefix p: <http://parking.kmi.open.ac.uk/ontologies/parking#> .
@prefix s: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix g: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix o: <http://linkedgeodata.org/ontology/> .
<http://parking.kmi.open.ac.uk/data/parks/4751.3> a o:Parking ;
g:lat "50.8509406"^^d:double ;
g:long "-0.983707"^^d:double ;
p:binaryAvailability "true"^^d:boolean .
<http://parking.kmi.open.ac.uk/data/parks/4934.6> a o:Parking ;
g:lat "50.8737457"^^d:double ;
g:long "-0.9731118"^^d:double ;
p:binaryAvailability "true"^^d:boolean .
<http://parking.kmi.open.ac.uk/data/parks/4934.8> a o:Parking ;
g:lat "50.873617"^^d:double ;
g:long "-0.9722267"^^d:double ;
p:binaryAvailability "true"^^d:boolean .
<http://parking.kmi.open.ac.uk/data/parks/4934.3> a o:Parking ; …Run Code Online (Sandbox Code Playgroud) 我刚刚导入了jena库来eclipse在rdf-s上工作,这是我的第一次尝试,但我无法读取乌龟(.ttl)文件.
我用以下方式尝试了它:
import java.io.*;
import java.util.*;
import com.hp.hpl.jena.rdf.model.*;
public class Simpsons {
public static void main(String[] args) throws IOException {
Model model=ModelFactory.createDefaultModel();
model.read(new FileInputStream("simpsons.ttl"),null);
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误如下:
Exception in thread "main" org.apache.jena.riot.RiotException: [line: 1, col: 1 ] Content is not allowed in prolog.
at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.fatal(ErrorHandlerFactory.java:136)
at org.apache.jena.riot.lang.LangRDFXML$ErrorHandlerBridge.fatalError(LangRDFXML.java:252)
at com.hp.hpl.jena.rdf.arp.impl.ARPSaxErrorHandler.fatalError(ARPSaxErrorHandler.java:48)
at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.warning(XMLHandler.java:209)
at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.fatalError(XMLHandler.java:239)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) …Run Code Online (Sandbox Code Playgroud) 我是SPARQL和RDF的新手,我想知道SPARQL中下面的确切含义是什么?
[] vc:n ?vcard .
Run Code Online (Sandbox Code Playgroud)
完整的查询是
PREFIX vc: <http://www.w3.org/2006/vcard/ns#>
SELECT ?given ?family
WHERE{
[] vc:n ?vcard .
OPTIONAL {?vcard vc:given-name ?given .}
OPTIONAL {?vcard vc:family-name ?family .}
}
Run Code Online (Sandbox Code Playgroud) 在W3C 的 RDF Turtle 文档中,我遇到了两个使用电子邮件地址作为 IRI 的示例(16 和 17):
_:b <http://xmlns.com/foaf/0.1/mbox> <bob@example.com> .
Run Code Online (Sandbox Code Playgroud)
据我了解,如果电子邮件地址前面带有适当的方案(即mailto:bob@example.com. 如果上例中的电子邮件地址应该是有效的 URI,则该语句实际上应为:
_:b <http://xmlns.com/foaf/0.1/mbox> <mailto:bob@example.com> .
Run Code Online (Sandbox Code Playgroud)
这是文档中的错误还是 IRI(与 URI 相对)不需要方案?
这些陈述是否相同?如果我删除owl:Restriction和有任何问题owl:Class.它们看起来似乎是多余的,但这总是我在网上看到的例子. owl:onProperty有域名owl:restriction,owl:restriction是一个子类owl:class.
:myClass owl:equivalentClass
[a owl:Class ;
owl:intersectionOf (
[ a owl:Restriction ; owl:onProperty :hasProp ; owl:allValuesFrom :SomeOtherClass ]
[ a owl:Restriction ; owl:onProperty :hasChild ; owl:someValuesFrom :SomeOtherClass ] ) ] .
:myClass owl:equivalentClass
[owl:intersectionOf (
[ owl:onProperty :hasProp ; owl:allValuesFrom :SomeOtherClass ]
[ owl:onProperty :hasProp ; owl:someValuesFrom :SomeOtherClass ] )
] .
Run Code Online (Sandbox Code Playgroud) .ttl文件是否可以包含对其他.ttl文件的引用?(以C语言的#include形式工作)
考虑以下RDF:
semapi:BaseClass a rdfs:Class;
rdfs:subClassOf rdfs:Class .
semapi:hasChainTo a rdf:Property;
rdfs:domain semapi:BaseClass;
rdfs:range semapi:BaseClass .
semapi:DerivedClass a rdfs:Class; rdfs:subClassOf semapi:BaseClass .
instances:Instance1 a semapi:DerivedClass;
semapi:hasChainTo (
[
a semapi:DerivedClass;
semapi:hasChainTo (
[C1]
[C2]
)
]
)
Run Code Online (Sandbox Code Playgroud)
如果semapi:hasChainTo rdfs:range semapi:BaseClass那么它意味着列表是rdf:type semapi:BaseClass.
我真正的意思是说每个项目在列表rdf:type(EI, [C1] rdf:type semapi:BaseClass,[C2] rdf:type semapi:BaseClass,...)
我怎样才能做到这一点?我需要猫头鹰(最好不要)吗?
我有以下有效的Turtle语法:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix sc: <http://education.data.gov.uk/def/school/School#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos>.
<http://example.com/schools/#1000> a <http://education.data.gov.uk/def/school/School> .
<http://example.com/schools/#1000> <http://education.data.gov.uk/def/school/establishmentName> "Atherstone Early Years Centre".
<http://example.com/schools/#1000> <http://education.data.gov.uk/def/school/establishmentNumber> "1000".
<http://example.com/schools/#1000> <http://education.data.gov.uk/def/school/Address> [<http://education.data.gov.uk/def/school/address1> "RATCLIFFE ROAD"; <http://education.data.gov.uk/def/school/postcode> "CV9 1LF"].
<http://example.com/schools/#1000> <http://education.data.gov.uk/def/school/establishmentType> "Nursery".
<http://example.com/schools/#1000> <http://education.data.gov.uk/def/school/districtAdministrative> "North Warwickshire".
<http://example.com/schools/#1000> <http://education.data.gov.uk/def/school/uniqueReferenceNumber> "2016".
<http://example.com/schools/#1000> geo:lat "52.5786677".
<http://example.com/schools/#1000> geo:long "-1.5420408".
Run Code Online (Sandbox Code Playgroud)
我基本上定义了一个学校对象,id#1000之后我添加了属性.我想知道我是否可以<http://example.com/schools/#1000>在每个属性之前摆脱定义,并以某种方式用括号或其他东西包围属性.有任何想法吗?