我正在尝试从 Turtle 文件中读取 RDF(如下所示),但我遇到了两个问题。首先,RDF 或 Turtle 中的空白是否存在问题?有时,我在阅读类似 URI 时遇到问题<I/O Performance>
。当我删除空格时,问题就消失了,给<IOPerformance>
. 在下面的文件中,我遇到了这个问题<Standard(M1) - Small(default)>
。这是我加载文件并列出每个三元组的主语、谓语和宾语的代码。
StmtIterator iter = model.listStatements();
while (iter.hasNext()) {
Statement stmt = iter.nextStatement();
Resource subject = stmt.getSubject(); // sujeito
Property predicate = stmt.getPredicate(); // predicado
RDFNode object = stmt.getObject(); // objeto
System.out.println((subject.getLocalName());
System.out.println((predicate.getLocalName().toString());
System.out.println(StringUtils.substringBetween(object.toString(),"", "^"));
}
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix legal: <http://www.linked-usdl.org/ns/usdl-legal#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix vann: <http://purl.org/vocab/vann/> .
@prefix org: <http://www.w3.org/ns/org#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix price: <http://www.linked-usdl.org/ns/usdl-price#> .
@prefix usdl: <http://www.linked-usdl.org/ns/usdl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dei: <http://dei.uc.pt/rdf/dei#> .
@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
<Standard(M1) - Small(default)>
rdfs:CPU "1 EC2 Compute Unit"^^xsd:string ;
rdfs:Cost "0.08"^^xsd:float ;
rdfs:EBS-OptimizedAvailable
"false"^^xsd:boolean ;
rdfs:IOPerformance "Moderate"^^xsd:string ;
rdfs:OS "Linux/UNIX"^^xsd:string ;
rdfs:Platform "32-bit"^^xsd:string ;
rdfs:RAM "1.7"^^xsd:float ;
rdfs:Storage "160"^^xsd:float .